From fd04821b339dca2818c6367378148a372f479fcf Mon Sep 17 00:00:00 2001 From: gianlucaguarini Date: Sat, 16 Oct 2021 20:38:40 +0200 Subject: [PATCH] fixed: transformation without config file --- .eslintrc | 4 ++-- index.js | 10 +++------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.eslintrc b/.eslintrc index 4a18e64..77674f8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,7 +1,7 @@ extends: eslint-config-riot parserOptions: - ecmaVersion: 2018 + ecmaVersion: 2021 sourceType: 'module' globals: @@ -9,4 +9,4 @@ globals: expect: true rules: - fp/no-class: off \ No newline at end of file + fp/no-class: off diff --git a/index.js b/index.js index 3a1f67c..44fef97 100644 --- a/index.js +++ b/index.js @@ -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] } }) - - -