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

Commit 31d6589

Browse files
authoredNov 25, 2019
fix: name of esModule option in source code (#346)
1 parent 2a18cba commit 31d6589

5 files changed

+25
-25
lines changed
 

‎src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ export default function loader(content) {
5959
this.emitFile(outputPath, content);
6060
}
6161

62-
const esModules =
63-
typeof options.esModules !== 'undefined' ? options.esModules : true;
62+
const esModule =
63+
typeof options.esModule !== 'undefined' ? options.esModule : true;
6464

65-
return `${esModules ? 'export default' : 'module.exports ='} ${publicPath};`;
65+
return `${esModule ? 'export default' : 'module.exports ='} ${publicPath};`;
6666
}
6767

6868
export const raw = true;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`"esModule" option should work with "Boolean" value equal "false": errors 1`] = `Array []`;
4+
5+
exports[`"esModule" option should work with "Boolean" value equal "false": result 1`] = `"9c87cbf3ba33126ffd25ae7f2f6bbafb.png"`;
6+
7+
exports[`"esModule" option should work with "Boolean" value equal "false": warnings 1`] = `Array []`;
8+
9+
exports[`"esModule" option should work with "Boolean" value equal "true": errors 1`] = `Array []`;
10+
11+
exports[`"esModule" option should work with "Boolean" value equal "true": result 1`] = `"9c87cbf3ba33126ffd25ae7f2f6bbafb.png"`;
12+
13+
exports[`"esModule" option should work with "Boolean" value equal "true": warnings 1`] = `Array []`;
14+
15+
exports[`"esModule" option should work without value: errors 1`] = `Array []`;
16+
17+
exports[`"esModule" option should work without value: result 1`] = `"9c87cbf3ba33126ffd25ae7f2f6bbafb.png"`;
18+
19+
exports[`"esModule" option should work without value: warnings 1`] = `Array []`;

‎test/__snapshots__/esModules-option.test.js.snap

-19
This file was deleted.

‎test/__snapshots__/validate-options.test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ exports[`validate options should throw an error on the "emitFile" option with "t
1212
-> Enables/Disables emit files (https://github.com/webpack-contrib/file-loader#emitfile)."
1313
`;
1414

15-
exports[`validate options should throw an error on the "esModules" option with "true" value 1`] = `
15+
exports[`validate options should throw an error on the "esModule" option with "true" value 1`] = `
1616
"Invalid options object. File Loader has been initialised using an options object that does not match the API schema.
17-
- options.esModules should be a boolean."
17+
- options.esModule should be a boolean."
1818
`;
1919

2020
exports[`validate options should throw an error on the "name" option with "true" value 1`] = `

‎test/validate-options.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('validate options', () => {
2626
success: [/image\.png/, 'image.png'],
2727
failure: [true],
2828
},
29-
esModules: {
29+
esModule: {
3030
success: [true, false],
3131
failure: ['true'],
3232
},

6 commit comments

Comments
 (6)

sepe81 commented on Jan 16, 2020

@sepe81

Starting from this commit and with file-loader 5.0.1 and 5.0.2 (but not 5.0.0) I get the "error" from #212

I don't understand why this happens, but guess it's related to the evaluation of the default value. Unfortunately I don't have any isolated example yet.

When I I explicitly set the option esModule to false it works.

          loader: 'file-loader',
          options: {
            esModule: false,
            ...
          }

alexander-akait commented on Jan 16, 2020

@alexander-akait
Member

Update css-loader to latest version

sepe81 commented on Jan 16, 2020

@sepe81

Thank you for the quick reply.

Some days ago I updated to "css-loader": "3.4.1" but with the newest release 3.4.2 AND without esModule: false it doesn't work either.

In my concrete case it is an image resource that doesn't work, so file-loader seems to be the relevant loader.

alexander-akait commented on Jan 16, 2020

@alexander-akait
Member

What is happens, maybe you can provide a screenshot?

sepe81 commented on Jan 16, 2020

@sepe81

I continued to search for similar problems and found [1]. According to [2] esModule is true by default starting with version 5.0.0.

Could it be, that this (breaking change) didn't work in 5.0.0 and has been fixed with 5.0.1? According to [3] this was just a rename from esModules to esModule.

[1] https://stackoverflow.com/questions/59114479/when-i-using-file-loader-and-html-loader-in-webpack-the-src-attr-of-image-gonna
[2] https://github.com/webpack-contrib/file-loader/releases/tag/v5.0.0
[3] #346

alexander-akait commented on Jan 16, 2020

@alexander-akait
Member

The problem in html-loader, and will be fixed in next html-loader release, 5.0.1 just fix due typo in source code

This repository has been archived.