closes #21
This commit is contained in:
parent
57c28c90d6
commit
141269364e
10
index.js
10
index.js
@ -1,7 +1,7 @@
|
||||
const { compile } = require('@riotjs/compiler')
|
||||
const { Transformer } = require('@parcel/plugin')
|
||||
const SourceMap = require('@parcel/source-map').default
|
||||
const { relative } = require('path')
|
||||
const { basename } = require('path')
|
||||
|
||||
/**
|
||||
* Generate the hmr code depending on the tag generated by the compiler
|
||||
@ -30,6 +30,10 @@ module.exports = new Transformer({
|
||||
}
|
||||
)
|
||||
|
||||
if (riotConfig && riotConfig.filePath.endsWith('.js')) {
|
||||
config.invalidateOnStartup()
|
||||
}
|
||||
|
||||
return riotConfig?.contents ?? {}
|
||||
},
|
||||
async transform({asset, config, options}) {
|
||||
@ -40,9 +44,11 @@ module.exports = new Transformer({
|
||||
file: asset.filePath,
|
||||
...config
|
||||
})
|
||||
// the suffix will be added only for the HMR
|
||||
const suffix = config?.hot ? hotReload(basename(asset.filePath)) : ''
|
||||
|
||||
asset.type = 'js'
|
||||
asset.setCode(`${code}${config?.hot ? hotReload(relative(options.projectRoot, asset.filePath)) : ''}`)
|
||||
asset.setCode(`${code}${suffix}`)
|
||||
asset.setMap(sourceMap.addVLQMap(map))
|
||||
|
||||
return [asset]
|
||||
|
||||
815
package-lock.json
generated
815
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -17,10 +17,10 @@
|
||||
"url": "https://github.com/riot/parcel-plugin-riot"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@riotjs/compiler": "^6.0.0"
|
||||
"@riotjs/compiler": "^6.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.30.0",
|
||||
"eslint": "^8.1.0",
|
||||
"eslint-config-riot": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user