Skip to content

Commit de076f5

Browse files
hjdivadrwjblue
andcommitted
Improve v1 API warning
Previously the warning did not provide much context: now include the config in the warning so there's something useful for the user to search in node_modules. Co-authored-by: Robert Jackson <[email protected]>
1 parent 985b61c commit de076f5

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/utils/normalize-options.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,13 @@ function parseFlags(options) {
9595
}
9696

9797
if (legacyFeatures || legacyEnvFlags) {
98+
let msg = `[babel-plugin-debug-macros]: passed v1 configuration, converting to v2. Legacy configuration passed:\n${JSON.stringify(
99+
options,
100+
null,
101+
2
102+
)}`;
98103
// eslint-disable-next-line no-console
99-
console.warn(
100-
'babel-plugin-debug-macros configuration API has changed, please update your configuration'
101-
);
104+
console.warn(msg);
102105
}
103106

104107
return combinedFlags;

tests/normalize-options-test.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('normalizeOptions', function() {
3030
let warnings = [];
3131
console.warn = warning => warnings.push(warning); // eslint-disable-line
3232

33-
let actual = normalizeOptions({
33+
let options = {
3434
envFlags: {
3535
source: '@ember/env-flags',
3636
flags: {
@@ -48,8 +48,9 @@ describe('normalizeOptions', function() {
4848
FEATURE_B: null,
4949
},
5050
},
51-
});
52-
51+
};
52+
let stringifiedOptions = JSON.stringify(options, null, 2);
53+
let actual = normalizeOptions(options);
5354
let expected = {
5455
debugTools: {
5556
isDebug: false,
@@ -70,7 +71,7 @@ describe('normalizeOptions', function() {
7071

7172
expect(actual).toEqual(expected);
7273
expect(warnings).toEqual([
73-
'babel-plugin-debug-macros configuration API has changed, please update your configuration',
74+
`[babel-plugin-debug-macros]: passed v1 configuration, converting to v2. Legacy configuration passed:\n${stringifiedOptions}`,
7475
]);
7576
});
7677

0 commit comments

Comments
 (0)