From 63b41beed479aa67b453d352c60b6e91fa54c99f Mon Sep 17 00:00:00 2001 From: Alexey Lavinsky Date: Thu, 24 Sep 2020 23:59:18 +0300 Subject: [PATCH] refactor: emoji deprecate BREAKING CHANGE: `emoji` was deprecated --- src/utils.js | 6 ++++++ test/__snapshots__/modules-option.test.js.snap | 9 +++++++++ test/modules-option.test.js | 12 ++++++++++++ 3 files changed, 27 insertions(+) diff --git a/src/utils.js b/src/utils.js index c3990f10..39a85979 100644 --- a/src/utils.js +++ b/src/utils.js @@ -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; } diff --git a/test/__snapshots__/modules-option.test.js.snap b/test/__snapshots__/modules-option.test.js.snap index 16f2cdeb..08d773b6 100644 --- a/test/__snapshots__/modules-option.test.js.snap +++ b/test/__snapshots__/modules-option.test.js.snap @@ -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`] = ` diff --git a/test/modules-option.test.js b/test/modules-option.test.js index 06b7cd27..1bb121ae 100644 --- a/test/modules-option.test.js +++ b/test/modules-option.test.js @@ -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'); + }); });