Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop deprecated config format #94

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions src/utils/normalize-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,50 +60,6 @@ function parseFlags(options) {
}
});

let legacyEnvFlags = options.envFlags;
if (legacyEnvFlags) {
let source = legacyEnvFlags.source;
combinedFlags[source] = combinedFlags[source] || {};

for (let flagName in legacyEnvFlags.flags) {
let flagValue = legacyEnvFlags.flags[flagName];
combinedFlags[source][flagName] = evaluateFlagValue(options, null, flagName, flagValue);
}
}

let legacyFeatures = options.features;
if (legacyFeatures) {
if (!Array.isArray(legacyFeatures)) {
legacyFeatures = [legacyFeatures];
}

legacyFeatures.forEach((flagsDefinition) => {
let source = flagsDefinition.source;
let flagsForSource = (combinedFlags[source] = combinedFlags[source] || {});

for (let flagName in flagsDefinition.flags) {
let flagValue = flagsDefinition.flags[flagName];

flagsForSource[flagName] = evaluateFlagValue(
options,
flagsDefinition.name,
flagName,
flagValue
);
}
});
}

if (legacyFeatures || legacyEnvFlags) {
let msg = `[babel-plugin-debug-macros]: passed v1 configuration, converting to v2. Legacy configuration passed:\n${JSON.stringify(
options,
null,
2
)}`;

console.warn(msg);
}

return combinedFlags;
}

Expand Down
71 changes: 18 additions & 53 deletions tests/create-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,63 +173,28 @@ function createTests(options) {
});

describe('ember-cli-babel configuration', function () {
describe('Ember < 3.27', function () {
describe('legacy config API', function () {
beforeEach(function () {
console.warn = () => {};
});

let h = transformTestHelper({
presets,
plugins: [
[
DebugToolsPlugin,
{
externalizeHelpers: {
global: 'Ember',
},
debugTools: {
isDebug: true,
source: '@ember/debug',
assertPredicateIndex: 1,
},
envFlags: {
source: '@glimmer/env',
flags: {
DEBUG: true,
},
},
describe('default configuration', function () {
let h = transformTestHelper({
presets,
plugins: [
[
DebugToolsPlugin,
{
externalizeHelpers: {
global: 'Ember',
},
],
],
});

h.generateTest('ember-cli-babel-config-pre-3-27');
});

describe('default configuration', function () {
let h = transformTestHelper({
presets,
plugins: [
[
DebugToolsPlugin,
{
externalizeHelpers: {
global: 'Ember',
},
debugTools: {
isDebug: true,
source: '@ember/debug',
assertPredicateIndex: 1,
},
flags: [{ source: '@glimmer/env', flags: { DEBUG: true } }],
debugTools: {
isDebug: true,
source: '@ember/debug',
assertPredicateIndex: 1,
},
],
flags: [{ source: '@glimmer/env', flags: { DEBUG: true } }],
},
],
});

h.generateTest('ember-cli-babel-config-pre-3-27');
],
});

h.generateTest('ember-cli-babel-config-pre-3-27');
});

describe('Ember >= 3.27', function () {
Expand Down
49 changes: 0 additions & 49 deletions tests/normalize-options-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,6 @@ describe('normalizeOptions', function () {
expect(actual).toEqual(expected);
});

it('converts "old style" options into the newer style (with deprecation)', function () {
let warnings = [];
console.warn = warning => warnings.push(warning); // eslint-disable-line

let options = {
envFlags: {
source: '@ember/env-flags',
flags: {
DEBUG: false,
},
},
debugTools: {
source: '@ember/debug-tools',
},
features: {
name: 'ember-source',
source: '@ember/features',
flags: {
FEATURE_A: true,
FEATURE_B: null,
},
},
};
let stringifiedOptions = JSON.stringify(options, null, 2);
let actual = normalizeOptions(options);
let expected = {
debugTools: {
isDebug: false,
assertPredicateIndex: undefined,
debugToolsImport: '@ember/debug-tools',
},
flags: {
'@ember/env-flags': {
DEBUG: false,
},
'@ember/features': {
FEATURE_A: true,
FEATURE_B: null,
},
},
externalizeHelpers: undefined,
};

expect(actual).toEqual(expected);
expect(warnings).toEqual([
`[babel-plugin-debug-macros]: passed v1 configuration, converting to v2. Legacy configuration passed:\n${stringifiedOptions}`,
]);
});

it('sets flag to false when svelte version matches the flag version', function () {
let actual = normalizeOptions({
debugTools: {
Expand Down
Loading