Skip to content

Commit

Permalink
refactor: emoji deprecate
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `emoji` was deprecated
  • Loading branch information
cap-Bernardito authored Sep 24, 2020
1 parent 9f974be commit 63b41be
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ function getModulesOptions(rawOptions, loaderContext) {
}
}

if (/\[emoji(?::(\d+))?\]/i.test(modulesOptions.localIdentName)) {
loaderContext.emitWarning(
'Emoji is deprecated and will be removed in next major release.'
);
}

return modulesOptions;
}

Expand Down
9 changes: 9 additions & 0 deletions test/__snapshots__/modules-option.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,15 @@ Array [

exports[`"modules" option should dedupe same modules in one module (issue #1037): warnings 1`] = `Array []`;

exports[`"modules" option should emit warning when localIdentName is emoji: errors 1`] = `Array []`;

exports[`"modules" option should emit warning when localIdentName is emoji: warnings 1`] = `
Array [
"ModuleWarning: Module Warning (from \`replaced original path\`):
(Emitted value instead of an instance of Error) Emoji is deprecated and will be removed in next major release.",
]
`;

exports[`"modules" option should keep order: errors 1`] = `Array []`;

exports[`"modules" option should keep order: module 1`] = `
Expand Down
12 changes: 12 additions & 0 deletions test/modules-option.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1389,4 +1389,16 @@ describe('"modules" option', () => {
expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});

it('should emit warning when localIdentName is emoji', async () => {
const compiler = getCompiler('./modules/pure/pure.js', {
modules: {
localIdentName: '[emoji:0]',
},
});
const stats = await compile(compiler);

expect(getWarnings(stats)).toMatchSnapshot('warnings');
expect(getErrors(stats)).toMatchSnapshot('errors');
});
});

0 comments on commit 63b41be

Please sign in to comment.