fixed: transformation without config file
This commit is contained in:
parent
c4ab1cd473
commit
fd04821b33
@ -1,7 +1,7 @@
|
|||||||
extends: eslint-config-riot
|
extends: eslint-config-riot
|
||||||
|
|
||||||
parserOptions:
|
parserOptions:
|
||||||
ecmaVersion: 2018
|
ecmaVersion: 2021
|
||||||
sourceType: 'module'
|
sourceType: 'module'
|
||||||
|
|
||||||
globals:
|
globals:
|
||||||
@ -9,4 +9,4 @@ globals:
|
|||||||
expect: true
|
expect: true
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
fp/no-class: off
|
fp/no-class: off
|
||||||
|
|||||||
10
index.js
10
index.js
@ -23,14 +23,14 @@ function hotReload(path) {
|
|||||||
|
|
||||||
module.exports = new Transformer({
|
module.exports = new Transformer({
|
||||||
async loadConfig({config}) {
|
async loadConfig({config}) {
|
||||||
const { contents } = await config.getConfig(
|
const riotConfig = await config.getConfig(
|
||||||
['.riotrc', '.riotrc.js', 'riot.config.js'],
|
['.riotrc', '.riotrc.js', 'riot.config.js'],
|
||||||
{
|
{
|
||||||
packageKey: 'riot'
|
packageKey: 'riot'
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
return contents || {}
|
return riotConfig?.contents ?? {}
|
||||||
},
|
},
|
||||||
async transform({asset, config, options}) {
|
async transform({asset, config, options}) {
|
||||||
const source = await asset.getCode()
|
const source = await asset.getCode()
|
||||||
@ -41,14 +41,10 @@ module.exports = new Transformer({
|
|||||||
...config
|
...config
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
asset.type = 'js'
|
asset.type = 'js'
|
||||||
asset.setCode(`${code}${config.hot ? hotReload(relative(options.projectRoot, asset.filePath)) : ''}`)
|
asset.setCode(`${code}${config?.hot ? hotReload(relative(options.projectRoot, asset.filePath)) : ''}`)
|
||||||
asset.setMap(sourceMap.addVLQMap(map))
|
asset.setMap(sourceMap.addVLQMap(map))
|
||||||
|
|
||||||
return [asset]
|
return [asset]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user