fixed: transformation without config file

This commit is contained in:
gianlucaguarini 2021-10-16 20:38:40 +02:00
parent c4ab1cd473
commit fd04821b33
2 changed files with 5 additions and 9 deletions

View File

@ -1,7 +1,7 @@
extends: eslint-config-riot
parserOptions:
ecmaVersion: 2018
ecmaVersion: 2021
sourceType: 'module'
globals:

View File

@ -23,14 +23,14 @@ function hotReload(path) {
module.exports = new Transformer({
async loadConfig({config}) {
const { contents } = await config.getConfig(
const riotConfig = await config.getConfig(
['.riotrc', '.riotrc.js', 'riot.config.js'],
{
packageKey: 'riot'
}
)
return contents || {}
return riotConfig?.contents ?? {}
},
async transform({asset, config, options}) {
const source = await asset.getCode()
@ -41,14 +41,10 @@ module.exports = new Transformer({
...config
})
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))
return [asset]
}
})