@warp-drive-mirror/build-config 0.0.0-beta.6 → 0.0.0-beta.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/babel-macros.js +5 -2
- package/dist/babel-macros.js.map +1 -1
- package/dist/babel-plugin-transform-asserts.cjs +3 -3
- package/dist/babel-plugin-transform-asserts.cjs.map +1 -1
- package/dist/babel-plugin-transform-deprecations.cjs +18 -4
- package/dist/babel-plugin-transform-deprecations.cjs.map +1 -1
- package/dist/babel-plugin-transform-features.cjs +3 -3
- package/dist/babel-plugin-transform-features.cjs.map +1 -1
- package/dist/babel-plugin-transform-logging.cjs +2 -2
- package/dist/babel-plugin-transform-logging.cjs.map +1 -1
- package/dist/cjs-set-config.cjs +50 -15
- package/dist/cjs-set-config.cjs.map +1 -1
- package/dist/{deprecations-C0B5IT3G.js → deprecations-ChFQtx-4.js} +4 -2
- package/dist/deprecations-ChFQtx-4.js.map +1 -0
- package/dist/deprecations.js +1 -1
- package/dist/env.js +4 -1
- package/dist/env.js.map +1 -1
- package/dist/index.js +49 -14
- package/dist/index.js.map +1 -1
- package/package.json +21 -11
- package/unstable-preview-types/-private/utils/deprecations.d.ts +3 -1
- package/unstable-preview-types/-private/utils/deprecations.d.ts.map +1 -1
- package/unstable-preview-types/-private/utils/get-env.d.ts +3 -0
- package/unstable-preview-types/-private/utils/get-env.d.ts.map +1 -1
- package/unstable-preview-types/babel-macros.d.ts +3 -0
- package/unstable-preview-types/babel-macros.d.ts.map +1 -1
- package/unstable-preview-types/deprecation-versions.d.ts +16 -0
- package/unstable-preview-types/deprecation-versions.d.ts.map +1 -1
- package/unstable-preview-types/deprecations.d.ts +1 -0
- package/unstable-preview-types/deprecations.d.ts.map +1 -1
- package/unstable-preview-types/env.d.ts +3 -0
- package/unstable-preview-types/env.d.ts.map +1 -1
- package/unstable-preview-types/index.d.ts +7 -7
- package/dist/deprecations-C0B5IT3G.js.map +0 -1
package/dist/babel-macros.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { L as LOGGING } from './debugging-BzogyWJo.js';
|
|
2
2
|
import { C as CURRENT_FEATURES } from './canary-features-BzGSGY5j.js';
|
|
3
|
-
import { C as CURRENT_DEPRECATIONS } from './deprecations-
|
|
3
|
+
import { C as CURRENT_DEPRECATIONS } from './deprecations-ChFQtx-4.js';
|
|
4
4
|
|
|
5
5
|
const features = Object.keys(CURRENT_FEATURES);
|
|
6
6
|
const FEATURES = Object.assign({}, CURRENT_FEATURES);
|
|
@@ -36,7 +36,10 @@ function macros() {
|
|
|
36
36
|
flags: {
|
|
37
37
|
TESTING: true,
|
|
38
38
|
PRODUCTION: true,
|
|
39
|
-
DEBUG: true
|
|
39
|
+
DEBUG: true,
|
|
40
|
+
IS_RECORDING: true,
|
|
41
|
+
IS_CI: true,
|
|
42
|
+
SHOULD_RECORD: true
|
|
40
43
|
}
|
|
41
44
|
}, '@warp-drive-mirror/build-config/env']];
|
|
42
45
|
return plugins;
|
package/dist/babel-macros.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-macros.js","sources":["../src/babel-macros.ts"],"sourcesContent":["import * as LOGGING from './debugging.ts';\nimport * as CURRENT_FEATURES from './canary-features.ts';\nimport * as CURRENT_DEPRECATIONS from './deprecations.ts';\n\ntype FEATURE = keyof typeof CURRENT_FEATURES;\nconst features = Object.keys(CURRENT_FEATURES) as FEATURE[];\nconst FEATURES = Object.assign({}, CURRENT_FEATURES) as Record<FEATURE, boolean>;\nfeatures.forEach((feature) => {\n let featureValue = FEATURES[feature];\n if (featureValue === null) {\n FEATURES[feature] = false;\n }\n});\n\nconst config = {\n features: FEATURES,\n deprecations: Object.assign({}, CURRENT_DEPRECATIONS),\n debug: Object.assign({}, LOGGING),\n};\n\nexport function macros() {\n const TransformAsserts = import.meta.resolve('./babel-plugin-transform-asserts.cjs').slice(7);\n const TransformDeprecations = import.meta.resolve('./babel-plugin-transform-deprecations.cjs').slice(7);\n const TransformDebugLogging = import.meta.resolve('./babel-plugin-transform-logging.cjs').slice(7);\n const TransformFeatures = import.meta.resolve('./babel-plugin-transform-features.cjs').slice(7);\n\n let plugins = [\n [TransformAsserts, {}, '@warp-drive-mirror/build-config/asserts-stripping'],\n [\n TransformFeatures,\n {\n source: '@warp-drive-mirror/build-config/canary-features',\n flags: config.features,\n },\n '@warp-drive-mirror/build-config/canary-features-stripping',\n ],\n [\n TransformDeprecations,\n {\n source: '@warp-drive-mirror/build-config/deprecations',\n flags: config.deprecations,\n },\n '@warp-drive-mirror/build-config/deprecation-stripping',\n ],\n [\n TransformDebugLogging,\n {\n source: '@warp-drive-mirror/build-config/debugging',\n configKey: 'debug',\n flags: config.debug,\n },\n '@warp-drive-mirror/build-config/debugging-stripping',\n ],\n [\n TransformDebugLogging,\n {\n source: '@warp-drive-mirror/build-config/env',\n configKey: 'env',\n flags: {\n TESTING: true,\n PRODUCTION: true,\n DEBUG: true,\n },\n },\n '@warp-drive-mirror/build-config/env',\n ],\n ];\n\n return plugins;\n}\n"],"names":["features","Object","keys","CURRENT_FEATURES","FEATURES","assign","forEach","feature","featureValue","config","deprecations","CURRENT_DEPRECATIONS","debug","LOGGING","macros","TransformAsserts","import","meta","resolve","slice","TransformDeprecations","TransformDebugLogging","TransformFeatures","plugins","source","flags","configKey","TESTING","PRODUCTION","DEBUG"],"mappings":";;;;AAKA,MAAMA,QAAQ,GAAGC,MAAM,CAACC,IAAI,CAACC,gBAAgB,CAAc,CAAA;AAC3D,MAAMC,QAAQ,GAAGH,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEF,gBAAgB,CAA6B,CAAA;AAChFH,QAAQ,CAACM,OAAO,CAAEC,OAAO,IAAK;AAC5B,EAAA,IAAIC,YAAY,GAAGJ,QAAQ,CAACG,OAAO,CAAC,CAAA;EACpC,IAAIC,YAAY,KAAK,IAAI,EAAE;AACzBJ,IAAAA,QAAQ,CAACG,OAAO,CAAC,GAAG,KAAK,CAAA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,MAAM,CAACG,KAAAA;AAChB,GAAC,EACD,8CAA8C,CAC/C,EACD,CACES,qBAAqB,EACrB;AACEG,IAAAA,MAAM,EAAE,8BAA8B;AACtCE,IAAAA,SAAS,EAAE,KAAK;AAChBD,IAAAA,KAAK,EAAE;AACLE,MAAAA,OAAO,EAAE,IAAI;AACbC,MAAAA,UAAU,EAAE,IAAI;AAChBC,MAAAA,KAAK,EAAE,IAAA;
|
|
1
|
+
{"version":3,"file":"babel-macros.js","sources":["../src/babel-macros.ts"],"sourcesContent":["import * as LOGGING from './debugging.ts';\nimport * as CURRENT_FEATURES from './canary-features.ts';\nimport * as CURRENT_DEPRECATIONS from './deprecations.ts';\n\ntype FEATURE = keyof typeof CURRENT_FEATURES;\nconst features = Object.keys(CURRENT_FEATURES) as FEATURE[];\nconst FEATURES = Object.assign({}, CURRENT_FEATURES) as Record<FEATURE, boolean>;\nfeatures.forEach((feature) => {\n let featureValue = FEATURES[feature];\n if (featureValue === null) {\n FEATURES[feature] = false;\n }\n});\n\nconst config = {\n features: FEATURES,\n deprecations: Object.assign({}, CURRENT_DEPRECATIONS),\n debug: Object.assign({}, LOGGING),\n};\n\nexport function macros() {\n const TransformAsserts = import.meta.resolve('./babel-plugin-transform-asserts.cjs').slice(7);\n const TransformDeprecations = import.meta.resolve('./babel-plugin-transform-deprecations.cjs').slice(7);\n const TransformDebugLogging = import.meta.resolve('./babel-plugin-transform-logging.cjs').slice(7);\n const TransformFeatures = import.meta.resolve('./babel-plugin-transform-features.cjs').slice(7);\n\n let plugins = [\n [TransformAsserts, {}, '@warp-drive-mirror/build-config/asserts-stripping'],\n [\n TransformFeatures,\n {\n source: '@warp-drive-mirror/build-config/canary-features',\n flags: config.features,\n },\n '@warp-drive-mirror/build-config/canary-features-stripping',\n ],\n [\n TransformDeprecations,\n {\n source: '@warp-drive-mirror/build-config/deprecations',\n flags: config.deprecations,\n },\n '@warp-drive-mirror/build-config/deprecation-stripping',\n ],\n [\n TransformDebugLogging,\n {\n source: '@warp-drive-mirror/build-config/debugging',\n configKey: 'debug',\n flags: config.debug,\n },\n '@warp-drive-mirror/build-config/debugging-stripping',\n ],\n [\n TransformDebugLogging,\n {\n source: '@warp-drive-mirror/build-config/env',\n configKey: 'env',\n flags: {\n TESTING: true,\n PRODUCTION: true,\n DEBUG: true,\n IS_RECORDING: true,\n IS_CI: true,\n SHOULD_RECORD: true,\n },\n },\n '@warp-drive-mirror/build-config/env',\n ],\n ];\n\n return plugins;\n}\n"],"names":["features","Object","keys","CURRENT_FEATURES","FEATURES","assign","forEach","feature","featureValue","config","deprecations","CURRENT_DEPRECATIONS","debug","LOGGING","macros","TransformAsserts","import","meta","resolve","slice","TransformDeprecations","TransformDebugLogging","TransformFeatures","plugins","source","flags","configKey","TESTING","PRODUCTION","DEBUG","IS_RECORDING","IS_CI","SHOULD_RECORD"],"mappings":";;;;AAKA,MAAMA,QAAQ,GAAGC,MAAM,CAACC,IAAI,CAACC,gBAAgB,CAAc,CAAA;AAC3D,MAAMC,QAAQ,GAAGH,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEF,gBAAgB,CAA6B,CAAA;AAChFH,QAAQ,CAACM,OAAO,CAAEC,OAAO,IAAK;AAC5B,EAAA,IAAIC,YAAY,GAAGJ,QAAQ,CAACG,OAAO,CAAC,CAAA;EACpC,IAAIC,YAAY,KAAK,IAAI,EAAE;AACzBJ,IAAAA,QAAQ,CAACG,OAAO,CAAC,GAAG,KAAK,CAAA;AAC3B,GAAA;AACF,CAAC,CAAC,CAAA;AAEF,MAAME,MAAM,GAAG;AACbT,EAAAA,QAAQ,EAAEI,QAAQ;EAClBM,YAAY,EAAET,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEM,oBAAoB,CAAC;EACrDC,KAAK,EAAEX,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEQ,OAAO,CAAA;AAClC,CAAC,CAAA;AAEM,SAASC,MAAMA,GAAG;AACvB,EAAA,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,I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ACXC,MAAAA,aAAa,EAAE,IAAA;AACjB,KAAA;GACD,EACD,8BAA8B,CAC/B,CACF,CAAA;AAED,EAAA,OAAOT,OAAO,CAAA;AAChB;;;;"}
|
|
@@ -15,12 +15,12 @@ assert('foo', true);
|
|
|
15
15
|
(macroCondition(isDevelopingApp()) ? function assert(test) { if (!test) { throw new Error('foo'); } }(true) : {});
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
// => _macros.getGlobalConfig().
|
|
18
|
+
// => _macros.getGlobalConfig().WarpDriveMirror.env.DEBUG
|
|
19
19
|
function buildMacroConstDEBUG(types, binding, state) {
|
|
20
|
-
return types.memberExpression(types.memberExpression(types.memberExpression(types.callExpression(state.importer.import(binding, '@embroider/macros', 'getGlobalConfig'), []), types.identifier('
|
|
20
|
+
return types.memberExpression(types.memberExpression(types.memberExpression(types.callExpression(state.importer.import(binding, '@embroider/macros', 'getGlobalConfig'), []), types.identifier('WarpDriveMirror')), types.identifier('env')), types.identifier('DEBUG'));
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
// => _macros.macroCondition(_macros.getGlobalConfig().
|
|
23
|
+
// => _macros.macroCondition(_macros.getGlobalConfig().WarpDriveMirror.env.DEBUG)
|
|
24
24
|
function buildMacroConditionDEBUG(types, binding, state) {
|
|
25
25
|
return types.callExpression(state.importer.import(binding, '@embroider/macros', 'macroCondition'), [buildMacroConstDEBUG(types, binding, state)]);
|
|
26
26
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-transform-asserts.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-asserts.js"],"sourcesContent":["const { ImportUtil } = require('babel-import-util');\n\nconst Utils = new Set(['assert']);\n\n/*\n// Before\nimport { assert } from '@warp-drive-mirror/build-config/macros';\n\nassert('foo', true);\n\n// After\n(macroCondition(isDevelopingApp()) ? function assert(test) { if (!test) { throw new Error('foo'); } }(true) : {});\n*/\n\n// => _macros.getGlobalConfig().
|
|
1
|
+
{"version":3,"file":"babel-plugin-transform-asserts.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-asserts.js"],"sourcesContent":["const { ImportUtil } = require('babel-import-util');\n\nconst Utils = new Set(['assert']);\n\n/*\n// Before\nimport { assert } from '@warp-drive-mirror/build-config/macros';\n\nassert('foo', true);\n\n// After\n(macroCondition(isDevelopingApp()) ? function assert(test) { if (!test) { throw new Error('foo'); } }(true) : {});\n*/\n\n// => _macros.getGlobalConfig().WarpDriveMirror.env.DEBUG\nfunction buildMacroConstDEBUG(types, binding, state) {\n return types.memberExpression(\n types.memberExpression(\n types.memberExpression(\n types.callExpression(state.importer.import(binding, '@embroider/macros', 'getGlobalConfig'), []),\n types.identifier('WarpDriveMirror')\n ),\n types.identifier('env')\n ),\n types.identifier('DEBUG')\n );\n}\n\n// => _macros.macroCondition(_macros.getGlobalConfig().WarpDriveMirror.env.DEBUG)\nfunction buildMacroConditionDEBUG(types, binding, state) {\n return types.callExpression(state.importer.import(binding, '@embroider/macros', 'macroCondition'), [\n buildMacroConstDEBUG(types, binding, state),\n ]);\n}\n\n// (test) => { if (!test) { throw new Error(someMessage); } }(someCond)\nfunction buildAssert(types, originalCallExpression) {\n const desc = originalCallExpression.arguments[0];\n const test = originalCallExpression.arguments[1] ?? types.booleanLiteral(false);\n // prettier-ignore\n return types.callExpression(\n types.arrowFunctionExpression([types.identifier('test')], // (test) =>\n types.blockStatement([ // {\n types.ifStatement( // if\n types.unaryExpression('!', types.identifier('test')), // (!test)\n types.blockStatement([ // {\n types.throwStatement( // throw\n types.newExpression(types.identifier('Error'), [desc]) // new Error(desc)\n )]) // }\n )]) // }\n ),\n [test] // (someCond)\n );\n}\n\n// => ( <debug-macro> ? <assert-exp> : {});\nfunction buildAssertTernary(types, binding, state, originalCallExpression) {\n return types.expressionStatement(\n types.conditionalExpression(\n buildMacroConditionDEBUG(types, binding, state),\n buildAssert(types, originalCallExpression),\n types.objectExpression([])\n )\n );\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === '@warp-drive-mirror/build-config/macros') {\n const specifiers = path.get('specifiers');\n\n specifiers.forEach((specifier) => {\n const name = specifier.node.imported.name;\n if (!Utils.has(name)) {\n throw new Error(`Unexpected import '${name}' imported from '@warp-drive-mirror/build-config/macros'`);\n }\n\n const localBindingName = specifier.node.local.name;\n const binding = specifier.scope.getBinding(localBindingName);\n\n binding.referencePaths.forEach((p) => {\n const originalCallExpression = p.parentPath.node;\n\n if (!t.isCallExpression(originalCallExpression)) {\n throw new Error('Expected a call expression');\n }\n\n const assertTernary = buildAssertTernary(t, binding, state, originalCallExpression);\n p.parentPath.replaceWith(assertTernary);\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["ImportUtil","require","Utils","Set","buildMacroConstDEBUG","types","binding","state","memberExpression","callExpression","importer","import","identifier","buildMacroConditionDEBUG","buildAssert","originalCallExpression","desc","arguments","test","booleanLiteral","arrowFunctionExpression","blockStatement","ifStatement","unaryExpression","throwStatement","newExpression","buildAssertTernary","expressionStatement","conditionalExpression","objectExpression","babel","t","name","visitor","ImportDeclaration","path","importPath","node","source","value","specifiers","get","forEach","specifier","imported","has","Error","localBindingName","local","scope","getBinding","referencePaths","p","parentPath","isCallExpression","assertTernary","replaceWith","removeOwnBinding","remove","length","Program"],"mappings":";;AAAA,MAAM;AAAEA,EAAAA,UAAAA;AAAW,CAAC,GAAGC,OAAO,CAAC,mBAAmB,CAAC,CAAA;AAEnD,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,SAASC,oBAAoBA,CAACC,KAAK,E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C,EAAEI,IAAI,CAAC,CAAA;AAC1C,OAAA;AACF,KAAA;GACD,CAAA;AACH;;;;"}
|
|
@@ -33,12 +33,26 @@ function babelPluginTransformDeprecations (babel) {
|
|
|
33
33
|
negateStatement = true;
|
|
34
34
|
node = p.parentPath;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const comments = node.node.leadingComments ?? (node.parent.type === 'ConditionalExpression' && node.parent.leadingComments) ?? [];
|
|
37
|
+
let shouldInlineConfigValue = false;
|
|
38
|
+
if (comments?.length) {
|
|
39
|
+
const lastComment = comments.at(-1);
|
|
40
|
+
if (lastComment.value.trim() === 'inline-macro-config') {
|
|
41
|
+
shouldInlineConfigValue = true;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('WarpDriveMirror')), t.identifier('deprecations')), t.identifier(name));
|
|
45
|
+
const configExp = negateStatement ? t.unaryExpression('!', getConfig) : getConfig;
|
|
46
|
+
const replaceExp = shouldInlineConfigValue ?
|
|
47
|
+
// if (DEPRECATE_FOO)
|
|
48
|
+
// =>
|
|
49
|
+
// if (getGlobalConfig('WarpDriveMirror').deprecations.FOO)
|
|
50
|
+
configExp :
|
|
38
51
|
// if (DEPRECATE_FOO)
|
|
39
52
|
// =>
|
|
40
|
-
// if (macroCondition(getGlobalConfig('
|
|
41
|
-
t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [
|
|
53
|
+
// if (macroCondition(getGlobalConfig('WarpDriveMirror').deprecations.FOO))
|
|
54
|
+
t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [configExp]);
|
|
55
|
+
node.replaceWith(replaceExp);
|
|
42
56
|
});
|
|
43
57
|
specifier.scope.removeOwnBinding(localBindingName);
|
|
44
58
|
specifier.remove();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-transform-deprecations.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-deprecations.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'deprecation-flags',\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p, other) => {\n let negateStatement = false;\n let node = p;\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('
|
|
1
|
+
{"version":3,"file":"babel-plugin-transform-deprecations.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-deprecations.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'deprecation-flags',\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p, other) => {\n let negateStatement = false;\n let node = p;\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n const comments =\n node.node.leadingComments ??\n (node.parent.type === 'ConditionalExpression' && node.parent.leadingComments) ??\n [];\n let shouldInlineConfigValue = false;\n if (comments?.length) {\n const lastComment = comments.at(-1);\n if (lastComment.value.trim() === 'inline-macro-config') {\n shouldInlineConfigValue = true;\n }\n }\n\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('WarpDriveMirror')\n ),\n t.identifier('deprecations')\n ),\n t.identifier(name)\n );\n\n const configExp = negateStatement ? t.unaryExpression('!', getConfig) : getConfig;\n const replaceExp = shouldInlineConfigValue\n ? // if (DEPRECATE_FOO)\n // =>\n // if (getGlobalConfig('WarpDriveMirror').deprecations.FOO)\n configExp\n : // if (DEPRECATE_FOO)\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').deprecations.FOO))\n t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [configExp]);\n node.replaceWith(replaceExp);\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["parentIsUnary","node","parent","type","operator","babel","types","t","name","visitor","ImportDeclaration","path","state","importPath","source","value","opts","specifiers","get","forEach","specifier","imported","flags","Error","localBindingName","local","binding","scope","getBinding","referencePaths","p","other","negateStatement","parentPath","comments","leadingComments","shouldInlineConfigValue","length","lastComment","at","trim","getConfig","memberExpression","callExpression","importer","import","identifier","configExp","unaryExpression","replaceExp","replaceWith","removeOwnBinding","remove","Program","ImportUtil"],"mappings":";;;;AAEA,SAASA,aAAaA,CAACC,IAAI,EAAE;AAC3B,EAAA,IAAIA,IAAI,CAACC,MAAM,CAACC,IAAI,KAAK,iBAAiB,IAAIF,IAAI,CAACC,MAAM,CAACE,QA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;AACA;AACAxC,cAAAA,CAAC,CAACoC,cAAc,CAAC/B,KAAK,CAACgC,QAAQ,CAACC,MAAM,CAACf,CAAC,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,CAACiB,SAAS,CAAC,CAAC,CAAA;AAClG9C,cAAAA,IAAI,CAACiD,WAAW,CAACD,UAAU,CAAC,CAAA;AAC9B,aAAC,CAAC,CAAA;AACF7B,YAAAA,SAAS,CAACO,KAAK,CAACwB,gBAAgB,CAAC3B,gBAAgB,CAAC,CAAA;YAClDJ,SAAS,CAACgC,MAAM,EAAE,CAAA;AACpB,WAAC,CAAC,CAAA;UACF,IAAIzC,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAACmB,MAAM,KAAK,CAAC,EAAE;YACvC1B,IAAI,CAACyC,MAAM,EAAE,CAAA;AACf,WAAA;AACF,SAAA;OACD;AAEDC,MAAAA,OAAOA,CAAC1C,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAACgC,QAAQ,GAAG,IAAIU,0BAAU,CAAC/C,CAAC,EAAEI,IAAI,CAAC,CAAA;AAC1C,OAAA;AACF,KAAA;GACD,CAAA;AACH;;;;"}
|
|
@@ -4,7 +4,7 @@ const babelImportUtil = require('babel-import-util');
|
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
|
|
6
6
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
7
|
-
const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('babel-plugin-transform-features.cjs', document.baseURI).href))), 'utf-8'));
|
|
7
|
+
const pkg = JSON.parse(fs.readFileSync(new URL("../package.json", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('babel-plugin-transform-features.cjs', document.baseURI).href))), 'utf-8'));
|
|
8
8
|
const version = pkg.version;
|
|
9
9
|
const isCanary = version.includes('alpha');
|
|
10
10
|
function parentIsUnary(node) {
|
|
@@ -43,11 +43,11 @@ function babelPluginTransformFeatures (babel) {
|
|
|
43
43
|
negateStatement = true;
|
|
44
44
|
node = p.parentPath;
|
|
45
45
|
}
|
|
46
|
-
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('
|
|
46
|
+
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('WarpDriveMirror')), t.identifier('features')), t.identifier(name));
|
|
47
47
|
node.replaceWith(
|
|
48
48
|
// if (LOG_FOO)
|
|
49
49
|
// =>
|
|
50
|
-
// if (macroCondition(getGlobalConfig('
|
|
50
|
+
// if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO))
|
|
51
51
|
t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [negateStatement ? t.unaryExpression('!', getConfig) : getConfig]));
|
|
52
52
|
});
|
|
53
53
|
specifier.scope.removeOwnBinding(localBindingName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-transform-features.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-features.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\nimport fs from 'fs';\n\nconst pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));\nconst version = pkg.version;\n\nconst isCanary = version.includes('alpha');\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p) => {\n let negateStatement = false;\n let node = p;\n if (!isCanary) {\n p.replaceWith(t.boolean(state.opts.flags[name]));\n return;\n }\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('
|
|
1
|
+
{"version":3,"file":"babel-plugin-transform-features.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-features.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\nimport fs from 'fs';\n\nconst pkg = JSON.parse(fs.readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));\nconst version = pkg.version;\n\nconst isCanary = version.includes('alpha');\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p) => {\n let negateStatement = false;\n let node = p;\n if (!isCanary) {\n p.replaceWith(t.boolean(state.opts.flags[name]));\n return;\n }\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('WarpDriveMirror')\n ),\n t.identifier('features')\n ),\n t.identifier(name)\n );\n node.replaceWith(\n // if (LOG_FOO)\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO))\n t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [\n negateStatement ? t.unaryExpression('!', getConfig) : getConfig,\n ])\n );\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["pkg","JSON","parse","fs","readFileSync","version","isCanary","includes","parentIsUnary","node","parent","type","operator","babel","types","t","name","visitor","ImportDeclaration","path","state","importPath","source","value","opts","specifiers","get","forEach","specifier","imported","flags","Error","localBindingName","local","binding","scope","getBinding","referencePaths","p","negateStatement","replaceWith","boolean","parentPath","getConfig","memberExpression","callExpression","importer","import","identifier","unaryExpression","removeOwnBinding","remove","length","Program","ImportUtil"],"mappings":";;;;;;AAGA,MAAMA,GAAG,GAAGC,IAAI,CAACC,KAAK,CAACC,EAAE,CAACC,YAAY,CAAC,IAAA,GAAA,CAAA,iBAAA,EAAA,qRAAA,CAA2C,EAAE,OAAO,CAAC,CAAC,CAAA;AAC7F,MAAMC,OAAO,GAAGL,GAAG,CAACK,OAAO,CAAA;AAE3B,MAAMC,QAAQ,GAAGD,OAAO,CAACE,QAAQ,CAAC,OAAO,CAAC,CAAA;AAE1C,SAASC,aAAaA,CAACC,IAAI,EAAE;AAC3B,EAAA,IAAIA,IAAI,CAACC,MAAM,CAACC,IAAI,KAAK,iBAAiB,IAAIF,IAAI,CAACC,MAAM,CAACE,QAAQ,KAAK,GAAG,EAAE;AAC1E,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AACA,EAAA,OAAO,KAAK,CAAA;AACd,CAAA;AAEe,qCAAA,EAAUC,KAAK,EAAE;EAC9B,MAAM;A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AAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAAC0B,QAAQ,GAAG,IAAIQ,0BAAU,CAACvC,CAAC,EAAEI,IAAI,CAAC,CAAA;AAC1C,OAAA;AACF,KAAA;GACD,CAAA;AACH;;;;"}
|
|
@@ -34,11 +34,11 @@ function babelPluginTransformLogging (babel) {
|
|
|
34
34
|
negateStatement = true;
|
|
35
35
|
node = p.parentPath;
|
|
36
36
|
}
|
|
37
|
-
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('
|
|
37
|
+
let getConfig = t.memberExpression(t.memberExpression(t.memberExpression(t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []), t.identifier('WarpDriveMirror')), t.identifier(state.opts.configKey)), t.identifier(name));
|
|
38
38
|
node.replaceWith(
|
|
39
39
|
// if (LOG_FOO)
|
|
40
40
|
// =>
|
|
41
|
-
// if (macroCondition(getGlobalConfig('
|
|
41
|
+
// if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO))
|
|
42
42
|
t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [negateStatement ? t.unaryExpression('!', getConfig) : getConfig]));
|
|
43
43
|
});
|
|
44
44
|
specifier.scope.removeOwnBinding(localBindingName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"babel-plugin-transform-logging.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-logging.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p) => {\n let negateStatement = false;\n let node = p;\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('
|
|
1
|
+
{"version":3,"file":"babel-plugin-transform-logging.cjs","sources":["../cjs-src/transforms/babel-plugin-transform-logging.js"],"sourcesContent":["import { ImportUtil } from 'babel-import-util';\n\nfunction parentIsUnary(node) {\n if (node.parent.type === 'UnaryExpression' && node.parent.operator === '!') {\n return true;\n }\n return false;\n}\n\nexport default function (babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n ImportDeclaration(path, state) {\n const importPath = path.node.source.value;\n\n if (importPath === state.opts.source) {\n const specifiers = path.get('specifiers');\n specifiers.forEach((specifier) => {\n let name = specifier.node.imported.name;\n if (!(name in state.opts.flags)) {\n throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n binding.referencePaths.forEach((p) => {\n let negateStatement = false;\n let node = p;\n if (parentIsUnary(p)) {\n negateStatement = true;\n node = p.parentPath;\n }\n let getConfig = t.memberExpression(\n t.memberExpression(\n t.memberExpression(\n t.callExpression(state.importer.import(p, '@embroider/macros', 'getGlobalConfig'), []),\n t.identifier('WarpDriveMirror')\n ),\n t.identifier(state.opts.configKey)\n ),\n t.identifier(name)\n );\n node.replaceWith(\n // if (LOG_FOO)\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO))\n t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [\n negateStatement ? t.unaryExpression('!', getConfig) : getConfig,\n ])\n );\n });\n specifier.scope.removeOwnBinding(localBindingName);\n specifier.remove();\n });\n if (path.get('specifiers').length === 0) {\n path.remove();\n }\n }\n },\n\n Program(path, state) {\n state.importer = new ImportUtil(t, path);\n },\n },\n };\n}\n"],"names":["parentIsUnary","node","parent","type","operator","babel","types","t","name","visitor","ImportDeclaration","path","state","importPath","source","value","opts","specifiers","get","forEach","specifier","imported","flags","Error","localBindingName","local","binding","scope","getBinding","referencePaths","p","negateStatement","parentPath","getConfig","memberExpression","callExpression","importer","import","identifier","configKey","replaceWith","unaryExpression","removeOwnBinding","remove","length","Program","ImportUtil"],"mappings":";;;;AAEA,SAASA,aAAaA,CAACC,IAAI,EAAE;AAC3B,EAAA,IAAIA,IAAI,CAACC,MAAM,CAACC,IAAI,KAAK,iBAAiB,IAAIF,IAAI,CAACC,MAAM,CAACE,QAAQ,KAAK,GAAG,EAAE;AAC1E,IAAA,OAAO,IAAI,CAAA;AACb,GAAA;AACA,EAAA,OAAO,KAAK,CAAA;AACd,CAAA;AAEe,oCAAA,EAAUC,KAAK,EAAE;EAC9B,MAAM;AAAEC,IAAAA,KAAK,EAAEC,CAAAA;AAAE,GAAC,GAAGF,KAAK,CAAA;EAE1B,OAAO;AACLG,IAAAA,IAAI,EAAE,eAAe;AAAE;AACvBC,IAAAA,OAAO,EAAE;AACPC,MAAAA,iBAAiBA,CAACC,IAAI,EAAEC,KAAK,EAAE;QAC7B,MAAMC,UAAU,GAAGF,IAAI,CAACV,IAAI,CAACa,MAAM,CAACC,KAAK,CAAA;AAEzC,QAAA,IAAIF,UAAU,KAAKD,KAAK,CAACI,IAAI,CAACF,MAAM,EAAE;AACpC,UAAA,MAAMG,UAAU,GAAGN,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAAA;AACzCD,UAAAA,UAAU,CAACE,OAAO,CAAEC,SAAS,IAAK;YAChC,IAAIZ,IAAI,GAAGY,SAAS,CAACnB,IAAI,CAACoB,QAAQ,CAACb,IAAI,CAAA;YACvC,IAAI,E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CAACC,MAAM,CAACP,CAAC,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,CAChFC,eAAe,GAAGxB,CAAC,CAACkC,eAAe,CAAC,GAAG,EAAER,SAAS,CAAC,GAAGA,SAAS,CAChE,CACH,CAAC,CAAA;AACH,aAAC,CAAC,CAAA;AACFb,YAAAA,SAAS,CAACO,KAAK,CAACe,gBAAgB,CAAClB,gBAAgB,CAAC,CAAA;YAClDJ,SAAS,CAACuB,MAAM,EAAE,CAAA;AACpB,WAAC,CAAC,CAAA;UACF,IAAIhC,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAAC0B,MAAM,KAAK,CAAC,EAAE;YACvCjC,IAAI,CAACgC,MAAM,EAAE,CAAA;AACf,WAAA;AACF,SAAA;OACD;AAEDE,MAAAA,OAAOA,CAAClC,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAACwB,QAAQ,GAAG,IAAIU,0BAAU,CAACvC,CAAC,EAAEI,IAAI,CAAC,CAAA;AAC1C,OAAA;AACF,KAAA;GACD,CAAA;AACH;;;;"}
|
package/dist/cjs-set-config.cjs
CHANGED
|
@@ -14,15 +14,21 @@ function getEnv() {
|
|
|
14
14
|
EMBER_ENV,
|
|
15
15
|
IS_TESTING,
|
|
16
16
|
EMBER_CLI_TEST_COMMAND,
|
|
17
|
-
NODE_ENV
|
|
17
|
+
NODE_ENV,
|
|
18
|
+
CI,
|
|
19
|
+
IS_RECORDING
|
|
18
20
|
} = process.env;
|
|
19
21
|
const PRODUCTION = EMBER_ENV === 'production' || !EMBER_ENV && NODE_ENV === 'production';
|
|
20
22
|
const DEBUG = !PRODUCTION;
|
|
21
23
|
const TESTING = DEBUG || Boolean(EMBER_ENV === 'test' || IS_TESTING || EMBER_CLI_TEST_COMMAND);
|
|
24
|
+
const SHOULD_RECORD = Boolean(!CI || IS_RECORDING);
|
|
22
25
|
return {
|
|
23
26
|
TESTING,
|
|
24
27
|
PRODUCTION,
|
|
25
|
-
DEBUG
|
|
28
|
+
DEBUG,
|
|
29
|
+
IS_RECORDING: Boolean(IS_RECORDING),
|
|
30
|
+
IS_CI: Boolean(CI),
|
|
31
|
+
SHOULD_RECORD
|
|
26
32
|
};
|
|
27
33
|
}
|
|
28
34
|
|
|
@@ -488,6 +494,23 @@ const ENABLE_LEGACY_SCHEMA_SERVICE = '5.4';
|
|
|
488
494
|
*/
|
|
489
495
|
const DEPRECATE_EMBER_INFLECTOR = '5.3';
|
|
490
496
|
|
|
497
|
+
/**
|
|
498
|
+
* This is a special flag that can be used to opt-in early to receiving deprecations introduced in 6.x
|
|
499
|
+
* which have had their infra backported to 5.x versions of EmberData.
|
|
500
|
+
*
|
|
501
|
+
* When this flag is not present or set to `true`, the deprecations from the 6.x branch
|
|
502
|
+
* will not print their messages and the deprecation cannot be resolved.
|
|
503
|
+
*
|
|
504
|
+
* When this flag is present and set to `false`, the deprecations from the 6.x branch will
|
|
505
|
+
* print and can be resolved.
|
|
506
|
+
*
|
|
507
|
+
* @property DISABLE_7X_DEPRECATIONS
|
|
508
|
+
* @since 5.3
|
|
509
|
+
* @until 7.0
|
|
510
|
+
* @public
|
|
511
|
+
*/
|
|
512
|
+
const DISABLE_7X_DEPRECATIONS = '7.0';
|
|
513
|
+
|
|
491
514
|
const CURRENT_DEPRECATIONS = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
|
|
492
515
|
__proto__: null,
|
|
493
516
|
DEPRECATE_CATCH_ALL,
|
|
@@ -500,32 +523,44 @@ const CURRENT_DEPRECATIONS = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defi
|
|
|
500
523
|
DEPRECATE_NON_UNIQUE_PAYLOADS,
|
|
501
524
|
DEPRECATE_RELATIONSHIP_REMOTE_UPDATE_CLEARING_LOCAL_STATE,
|
|
502
525
|
DEPRECATE_STORE_EXTENDS_EMBER_OBJECT,
|
|
526
|
+
DISABLE_7X_DEPRECATIONS,
|
|
503
527
|
ENABLE_LEGACY_SCHEMA_SERVICE
|
|
504
528
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
505
529
|
|
|
506
530
|
function deprecationIsResolved(deprecatedSince, compatVersion) {
|
|
507
531
|
return semver.lte(semver.minVersion(deprecatedSince), semver.minVersion(compatVersion));
|
|
508
532
|
}
|
|
509
|
-
|
|
533
|
+
const NextMajorVersion = '6.';
|
|
534
|
+
function deprecationIsNextMajorCycle(deprecatedSince) {
|
|
535
|
+
return deprecatedSince.startsWith(NextMajorVersion);
|
|
536
|
+
}
|
|
537
|
+
function getDeprecations(compatVersion, deprecations) {
|
|
510
538
|
const flags = {};
|
|
511
539
|
const keys = Object.keys(CURRENT_DEPRECATIONS);
|
|
540
|
+
const DISABLE_7X_DEPRECATIONS = deprecations?.DISABLE_7X_DEPRECATIONS ?? true;
|
|
512
541
|
keys.forEach(flag => {
|
|
513
542
|
const deprecatedSince = CURRENT_DEPRECATIONS[flag];
|
|
543
|
+
const isDeactivatedDeprecationNotice = DISABLE_7X_DEPRECATIONS && deprecationIsNextMajorCycle(deprecatedSince);
|
|
514
544
|
let flagState = true; // default to no code-stripping
|
|
515
545
|
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
546
|
+
if (!isDeactivatedDeprecationNotice) {
|
|
547
|
+
// if we have a specific flag setting, use it
|
|
548
|
+
if (typeof deprecations?.[flag] === 'boolean') {
|
|
549
|
+
flagState = deprecations?.[flag];
|
|
550
|
+
} else if (compatVersion) {
|
|
551
|
+
// if we are told we are compatible with a version
|
|
552
|
+
// we check if we can strip this flag
|
|
553
|
+
const isResolved = deprecationIsResolved(deprecatedSince, compatVersion);
|
|
554
|
+
// if we've resolved, we strip (by setting the flag to false)
|
|
555
|
+
/*
|
|
522
556
|
if (DEPRECATED_FEATURE) {
|
|
523
557
|
// deprecated code path
|
|
524
558
|
} else {
|
|
525
559
|
// if needed a non-deprecated code path
|
|
526
560
|
}
|
|
527
|
-
|
|
528
|
-
|
|
561
|
+
*/
|
|
562
|
+
flagState = !isResolved;
|
|
563
|
+
}
|
|
529
564
|
}
|
|
530
565
|
|
|
531
566
|
// console.log(`${flag}=${flagState} (${deprecatedSince} <= ${compatVersion})`);
|
|
@@ -629,7 +664,7 @@ const CURRENT_FEATURES = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.definePr
|
|
|
629
664
|
SAMPLE_FEATURE_FLAG
|
|
630
665
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
631
666
|
|
|
632
|
-
const dirname = typeof __dirname !== 'undefined' ? __dirname : url.fileURLToPath(new URL(".", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('cjs-set-config.cjs', document.baseURI).href))));
|
|
667
|
+
const dirname = typeof __dirname !== 'undefined' ? __dirname : url.fileURLToPath(new URL(".", (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('cjs-set-config.cjs', document.baseURI).href))));
|
|
633
668
|
const relativePkgPath = path.join(dirname, '../package.json');
|
|
634
669
|
const version = JSON.parse(fs.readFileSync(relativePkgPath, 'utf-8')).version;
|
|
635
670
|
const isCanary = version.includes('alpha');
|
|
@@ -814,7 +849,7 @@ function setConfig(context, appRoot, config) {
|
|
|
814
849
|
const macros = recastMacrosConfig(_MacrosConfig.for(context, appRoot));
|
|
815
850
|
const isLegacySupport = config.___legacy_support;
|
|
816
851
|
const hasDeprecatedConfig = isLegacySupport && Object.keys(config).length > 1;
|
|
817
|
-
const hasInitiatedConfig = macros.globalConfig['
|
|
852
|
+
const hasInitiatedConfig = macros.globalConfig['WarpDriveMirror'];
|
|
818
853
|
|
|
819
854
|
// setConfig called by user prior to legacy support called
|
|
820
855
|
if (isLegacySupport && hasInitiatedConfig) {
|
|
@@ -840,7 +875,7 @@ function setConfig(context, appRoot, config) {
|
|
|
840
875
|
|
|
841
876
|
const debugOptions = Object.assign({}, LOGGING, config.debug);
|
|
842
877
|
const env = getEnv();
|
|
843
|
-
const DEPRECATIONS = getDeprecations(config.compatWith || null);
|
|
878
|
+
const DEPRECATIONS = getDeprecations(config.compatWith || null, config.deprecations);
|
|
844
879
|
const FEATURES = getFeatures(env.PRODUCTION);
|
|
845
880
|
const includeDataAdapterInProduction = typeof config.includeDataAdapterInProduction === 'boolean' ? config.includeDataAdapterInProduction : true;
|
|
846
881
|
const includeDataAdapter = env.PRODUCTION ? includeDataAdapterInProduction : true;
|
|
@@ -853,7 +888,7 @@ function setConfig(context, appRoot, config) {
|
|
|
853
888
|
features: FEATURES,
|
|
854
889
|
env
|
|
855
890
|
};
|
|
856
|
-
macros.setGlobalConfig(undefined, '
|
|
891
|
+
macros.setGlobalConfig(undefined, 'WarpDriveMirror', finalizedConfig);
|
|
857
892
|
}
|
|
858
893
|
|
|
859
894
|
exports.setConfig = setConfig;
|