Skip to content
This repository has been archived by the owner on Mar 17, 2021. It is now read-only.

Commit

Permalink
fix: name of esModule
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 25, 2019
1 parent 2a18cba commit 8913552
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 25 deletions.
6 changes: 3 additions & 3 deletions src/index.js
Expand Up @@ -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;
19 changes: 19 additions & 0 deletions 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 []`;
19 changes: 0 additions & 19 deletions test/__snapshots__/esModules-option.test.js.snap

This file was deleted.

4 changes: 2 additions & 2 deletions test/__snapshots__/validate-options.test.js.snap
Expand Up @@ -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`] = `
Expand Down
2 changes: 1 addition & 1 deletion test/validate-options.test.js
Expand Up @@ -26,7 +26,7 @@ describe('validate options', () => {
success: [/image\.png/, 'image.png'],
failure: [true],
},
esModules: {
esModule: {
success: [true, false],
failure: ['true'],
},
Expand Down

0 comments on commit 8913552

Please sign in to comment.