Compare commits

..

1 Commits
main ... v7.0.1

Author SHA1 Message Date
gianlucaguarini
f0440219dc 7.0.1 2021-10-16 20:38:46 +02:00
4 changed files with 568 additions and 280 deletions

View File

@ -3,7 +3,7 @@
[![NPM downloads][npm-downloads-image]][npm-url]
[![MIT License][license-image]][license-url]
The Riot.js official parcel transformer.
A parcel plugin for riot.js
## Important

View File

@ -1,10 +1,7 @@
const { compile } = require('@riotjs/compiler')
const { Transformer } = require('@parcel/plugin')
const SourceMap = require('@parcel/source-map').default
const { basename } = require('path')
const CONFIG_FILES = ['.riotrc', '.riotrc.js', 'riot.config.js']
const PACKAGE_KEY = 'riot'
const { relative } = require('path')
/**
* Generate the hmr code depending on the tag generated by the compiler
@ -27,18 +24,11 @@ function hotReload(path) {
module.exports = new Transformer({
async loadConfig({config}) {
const riotConfig = await config.getConfig(
CONFIG_FILES,
['.riotrc', '.riotrc.js', 'riot.config.js'],
{
packageKey: PACKAGE_KEY
packageKey: 'riot'
}
)
const shouldInvalidateOnStartup = riotConfig &&
riotConfig?.filePath?.endsWith('.js') ||
riotConfig?.filePath?.endsWith(CONFIG_FILES[0])
if (shouldInvalidateOnStartup) {
config.invalidateOnStartup()
}
return riotConfig?.contents ?? {}
},
@ -51,11 +41,8 @@ module.exports = new Transformer({
...config
})
// the suffix will be added only for the HMR
const suffix = config?.hot ? hotReload(basename(asset.filePath)) : ''
asset.type = 'js'
asset.setCode(`${code}${suffix}`)
asset.setCode(`${code}${config?.hot ? hotReload(relative(options.projectRoot, asset.filePath)) : ''}`)
asset.setMap(sourceMap.addVLQMap(map))
return [asset]

815
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@riotjs/parcel-transformer-riot",
"version": "7.0.2",
"version": "7.0.1",
"description": "The Riot.js official parcel transformer",
"main": "index.js",
"scripts": {
@ -17,10 +17,10 @@
"url": "https://github.com/riot/parcel-plugin-riot"
},
"peerDependencies": {
"@riotjs/compiler": "^6.0.4"
"@riotjs/compiler": "^6.0.0"
},
"devDependencies": {
"eslint": "^8.1.0",
"eslint": "^7.30.0",
"eslint-config-riot": "^3.0.0"
},
"dependencies": {