From 31d6589b71b471f83908e80380dff9b9eada2d06 Mon Sep 17 00:00:00 2001 From: Evilebot Tnawi Date: Mon, 25 Nov 2019 15:53:12 +0300 Subject: [PATCH] fix: name of `esModule` option in source code (#346) --- src/index.js | 6 +++--- .../esModule-option.test.js.snap | 19 +++++++++++++++++++ .../esModules-option.test.js.snap | 19 ------------------- .../validate-options.test.js.snap | 4 ++-- test/validate-options.test.js | 2 +- 5 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 test/__snapshots__/esModule-option.test.js.snap delete mode 100644 test/__snapshots__/esModules-option.test.js.snap diff --git a/src/index.js b/src/index.js index aad4a4e..af79d8f 100644 --- a/src/index.js +++ b/src/index.js @@ -59,10 +59,10 @@ export default function loader(content) { this.emitFile(outputPath, content); } - const esModules = - typeof options.esModules !== 'undefined' ? options.esModules : true; + const esModule = + typeof options.esModule !== 'undefined' ? options.esModule : true; - return `${esModules ? 'export default' : 'module.exports ='} ${publicPath};`; + return `${esModule ? 'export default' : 'module.exports ='} ${publicPath};`; } export const raw = true; diff --git a/test/__snapshots__/esModule-option.test.js.snap b/test/__snapshots__/esModule-option.test.js.snap new file mode 100644 index 0000000..0f696f6 --- /dev/null +++ b/test/__snapshots__/esModule-option.test.js.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`"esModule" option should work with "Boolean" value equal "false": errors 1`] = `Array []`; + +exports[`"esModule" option should work with "Boolean" value equal "false": result 1`] = `"9c87cbf3ba33126ffd25ae7f2f6bbafb.png"`; + +exports[`"esModule" option should work with "Boolean" value equal "false": warnings 1`] = `Array []`; + +exports[`"esModule" option should work with "Boolean" value equal "true": errors 1`] = `Array []`; + +exports[`"esModule" option should work with "Boolean" value equal "true": result 1`] = `"9c87cbf3ba33126ffd25ae7f2f6bbafb.png"`; + +exports[`"esModule" option should work with "Boolean" value equal "true": warnings 1`] = `Array []`; + +exports[`"esModule" option should work without value: errors 1`] = `Array []`; + +exports[`"esModule" option should work without value: result 1`] = `"9c87cbf3ba33126ffd25ae7f2f6bbafb.png"`; + +exports[`"esModule" option should work without value: warnings 1`] = `Array []`; diff --git a/test/__snapshots__/esModules-option.test.js.snap b/test/__snapshots__/esModules-option.test.js.snap deleted file mode 100644 index 1a66ce5..0000000 --- a/test/__snapshots__/esModules-option.test.js.snap +++ /dev/null @@ -1,19 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`"esModules" option should work with "Boolean" value equal "false": errors 1`] = `Array []`; - -exports[`"esModules" option should work with "Boolean" value equal "false": result 1`] = `"9c87cbf3ba33126ffd25ae7f2f6bbafb.png"`; - -exports[`"esModules" option should work with "Boolean" value equal "false": warnings 1`] = `Array []`; - -exports[`"esModules" option should work with "Boolean" value equal "true": errors 1`] = `Array []`; - -exports[`"esModules" option should work with "Boolean" value equal "true": result 1`] = `"9c87cbf3ba33126ffd25ae7f2f6bbafb.png"`; - -exports[`"esModules" option should work with "Boolean" value equal "true": warnings 1`] = `Array []`; - -exports[`"esModules" option should work without value: errors 1`] = `Array []`; - -exports[`"esModules" option should work without value: result 1`] = `"9c87cbf3ba33126ffd25ae7f2f6bbafb.png"`; - -exports[`"esModules" option should work without value: warnings 1`] = `Array []`; diff --git a/test/__snapshots__/validate-options.test.js.snap b/test/__snapshots__/validate-options.test.js.snap index 2246fd2..12d0886 100644 --- a/test/__snapshots__/validate-options.test.js.snap +++ b/test/__snapshots__/validate-options.test.js.snap @@ -12,9 +12,9 @@ exports[`validate options should throw an error on the "emitFile" option with "t -> Enables/Disables emit files (https://github.com/webpack-contrib/file-loader#emitfile)." `; -exports[`validate options should throw an error on the "esModules" option with "true" value 1`] = ` +exports[`validate options should throw an error on the "esModule" option with "true" value 1`] = ` "Invalid options object. File Loader has been initialised using an options object that does not match the API schema. - - options.esModules should be a boolean." + - options.esModule should be a boolean." `; exports[`validate options should throw an error on the "name" option with "true" value 1`] = ` diff --git a/test/validate-options.test.js b/test/validate-options.test.js index 94bd17d..c98cf4f 100644 --- a/test/validate-options.test.js +++ b/test/validate-options.test.js @@ -26,7 +26,7 @@ describe('validate options', () => { success: [/image\.png/, 'image.png'], failure: [true], }, - esModules: { + esModule: { success: [true, false], failure: ['true'], },