@warp-drive-mirror/build-config 5.6.0-alpha.3 → 5.6.0-alpha.4

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.
Files changed (49) hide show
  1. package/dist/babel-macros.js +45 -12
  2. package/dist/babel-macros.js.map +1 -1
  3. package/dist/babel-plugin-transform-asserts.cjs +2 -2
  4. package/dist/babel-plugin-transform-asserts.cjs.map +1 -1
  5. package/dist/babel-plugin-transform-deprecations.cjs +2 -2
  6. package/dist/babel-plugin-transform-deprecations.cjs.map +1 -1
  7. package/dist/babel-plugin-transform-features.cjs +2 -2
  8. package/dist/babel-plugin-transform-features.cjs.map +1 -1
  9. package/dist/babel-plugin-transform-logging.cjs +2 -2
  10. package/dist/babel-plugin-transform-logging.cjs.map +1 -1
  11. package/dist/canary-features-DF5hbs2w.js +170 -0
  12. package/dist/canary-features-DF5hbs2w.js.map +1 -0
  13. package/dist/canary-features.js +1 -1
  14. package/dist/cjs-set-config.cjs +174 -602
  15. package/dist/cjs-set-config.cjs.map +1 -1
  16. package/dist/{debugging-BtpYr1v0.js → debugging-VdsvkNjX.js} +80 -62
  17. package/dist/debugging-VdsvkNjX.js.map +1 -0
  18. package/dist/debugging.js +1 -1
  19. package/dist/deprecations-BVxAmwe9.js +549 -0
  20. package/dist/deprecations-BVxAmwe9.js.map +1 -0
  21. package/dist/deprecations.js +1 -1
  22. package/dist/env.js +124 -0
  23. package/dist/env.js.map +1 -1
  24. package/dist/index.js +12 -515
  25. package/dist/index.js.map +1 -1
  26. package/dist/macros.js +18 -0
  27. package/dist/macros.js.map +1 -1
  28. package/package.json +2 -5
  29. package/unstable-preview-types/babel-macros.d.ts +10 -0
  30. package/unstable-preview-types/babel-macros.d.ts.map +1 -1
  31. package/unstable-preview-types/canary-features.d.ts +97 -40
  32. package/unstable-preview-types/canary-features.d.ts.map +1 -1
  33. package/unstable-preview-types/debugging.d.ts +59 -48
  34. package/unstable-preview-types/debugging.d.ts.map +1 -1
  35. package/unstable-preview-types/deprecation-versions.d.ts +0 -469
  36. package/unstable-preview-types/deprecation-versions.d.ts.map +1 -1
  37. package/unstable-preview-types/deprecations.d.ts +504 -1
  38. package/unstable-preview-types/deprecations.d.ts.map +1 -1
  39. package/unstable-preview-types/env.d.ts +123 -0
  40. package/unstable-preview-types/env.d.ts.map +1 -1
  41. package/unstable-preview-types/index.d.ts +77 -13
  42. package/unstable-preview-types/index.d.ts.map +1 -1
  43. package/unstable-preview-types/macros.d.ts +16 -0
  44. package/unstable-preview-types/macros.d.ts.map +1 -1
  45. package/dist/canary-features-D1wplYmb.js +0 -113
  46. package/dist/canary-features-D1wplYmb.js.map +0 -1
  47. package/dist/debugging-BtpYr1v0.js.map +0 -1
  48. package/dist/deprecations-D_dBAPC9.js +0 -34
  49. package/dist/deprecations-D_dBAPC9.js.map +0 -1
@@ -1,7 +1,28 @@
1
- import { L as LOGGING } from './debugging-BtpYr1v0.js';
2
- import { C as CURRENT_FEATURES } from './canary-features-D1wplYmb.js';
3
- import { C as CURRENT_DEPRECATIONS } from './deprecations-D_dBAPC9.js';
1
+ import { L as LOGGING } from './debugging-VdsvkNjX.js';
2
+ import { C as CURRENT_FEATURES } from './canary-features-DF5hbs2w.js';
3
+ import { C as CURRENT_DEPRECATIONS } from './deprecations-BVxAmwe9.js';
4
4
 
5
+ /**
6
+ * Babel plugins that convert constants and expressions into [macroConditions](https://www.npmjs.com/package/@embroider/macros#the-macros)
7
+ * so that they can be stripped from the code during the build process.
8
+ *
9
+ * This allows us to have great DX around common configuration patterns
10
+ * while still being able to ship a small and fast library.
11
+ *
12
+ * Transforms
13
+ *
14
+ * - deprecation constants imported from `@warp-drive-mirror/build-config/deprecations`
15
+ * - feature flags imported from `@warp-drive-mirror/build-config/canary-features`
16
+ * - debug logging constants imported from `@warp-drive-mirror/build-config/debugging`
17
+ * - environment constants imported from `@warp-drive-mirror/build-config/env`
18
+ * - expressionts imported from `@warp-drive-mirror/build-config/macros`
19
+ *
20
+ * Addons and apps can use these plugins to match the code-stripping behaviors of
21
+ * ***Warp*Drive**. This is useful when managing migrations for canary features
22
+ * and deprecations.
23
+ *
24
+ * @module
25
+ */
5
26
  const features = Object.keys(CURRENT_FEATURES);
6
27
  const FEATURES = Object.assign({}, CURRENT_FEATURES);
7
28
  features.forEach(feature => {
@@ -15,24 +36,36 @@ const config = {
15
36
  deprecations: Object.assign({}, CURRENT_DEPRECATIONS),
16
37
  debug: Object.assign({}, LOGGING)
17
38
  };
39
+ /**
40
+ * @returns an array of Babel plugins that can be used for code-stripping
41
+ * based on the configuration supplied to `setConfig` and the current ENV.
42
+ *
43
+ * - deprecation constants imported from `@warp-drive-mirror/build-config/deprecations`
44
+ * - feature flags imported from `@warp-drive-mirror/build-config/canary-features`
45
+ * - debug logging constants imported from `@warp-drive-mirror/build-config/debugging`
46
+ * - environment constants imported from `@warp-drive-mirror/build-config/env`
47
+ * - expressionts imported from `@warp-drive-mirror/build-config/macros`
48
+ */
18
49
  function macros() {
19
50
  const TransformAsserts = import.meta.resolve('./babel-plugin-transform-asserts.cjs').slice(7);
20
51
  const TransformDeprecations = import.meta.resolve('./babel-plugin-transform-deprecations.cjs').slice(7);
21
52
  const TransformDebugLogging = import.meta.resolve('./babel-plugin-transform-logging.cjs').slice(7);
22
53
  const TransformFeatures = import.meta.resolve('./babel-plugin-transform-features.cjs').slice(7);
23
- let plugins = [[TransformAsserts, {}, '@warp-drive-mirror/build-config/asserts-stripping'], [TransformFeatures, {
24
- source: '@warp-drive-mirror/build-config/canary-features',
54
+ let plugins = [[TransformAsserts, {
55
+ sources: ['@warp-drive-mirror/build-config/macros', '@warp-drive/core/build-config/macros']
56
+ }, '@warp-drive/core/build-config/asserts-stripping'], [TransformFeatures, {
57
+ sources: ['@warp-drive-mirror/build-config/canary-features', '@warp-drive/core/build-config/canary-features'],
25
58
  flags: config.features
26
- }, '@warp-drive-mirror/build-config/canary-features-stripping'], [TransformDeprecations, {
27
- source: '@warp-drive-mirror/build-config/deprecations',
59
+ }, '@warp-drive/core/build-config/canary-features-stripping'], [TransformDeprecations, {
60
+ sources: ['@warp-drive-mirror/build-config/deprecations', '@warp-drive/core/build-config/deprecations'],
28
61
  flags: config.deprecations
29
- }, '@warp-drive-mirror/build-config/deprecation-stripping'], [TransformDebugLogging, {
30
- source: '@warp-drive-mirror/build-config/debugging',
62
+ }, '@warp-drive/core/build-config/deprecation-stripping'], [TransformDebugLogging, {
63
+ sources: ['@warp-drive-mirror/build-config/debugging', '@warp-drive/core/build-config/debugging'],
31
64
  configKey: 'debug',
32
65
  runtimeKey: 'activeLogging',
33
66
  flags: config.debug
34
- }, '@warp-drive-mirror/build-config/debugging-stripping'], [TransformDebugLogging, {
35
- source: '@warp-drive-mirror/build-config/env',
67
+ }, '@warp-drive/core/build-config/debugging-stripping'], [TransformDebugLogging, {
68
+ sources: ['@warp-drive-mirror/build-config/env', '@warp-drive/core/build-config/env'],
36
69
  configKey: 'env',
37
70
  flags: {
38
71
  TESTING: true,
@@ -42,7 +75,7 @@ function macros() {
42
75
  IS_CI: true,
43
76
  SHOULD_RECORD: true
44
77
  }
45
- }, '@warp-drive-mirror/build-config/env']];
78
+ }, '@warp-drive/core/build-config/env']];
46
79
  return plugins;
47
80
  }
48
81
 
@@ -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\ntype BabelPlugin = [string, Record<string, unknown>, string];\n\nexport function macros(): BabelPlugin[] {\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 runtimeKey: 'activeLogging',\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 ] satisfies BabelPlugin[];\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","runtimeKey","TESTING","PRODUCTION","DEBUG","IS_RECORDING","IS_CI","SHOULD_RECORD"],"mappings":";;;;AAKA,MAAMA,QAAQ,GAAGC,MAAM,CAACC,IAAI,CAACC,gBAAgB,CAAc;AAC3D,MAAMC,QAAQ,G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AAE,uCAAuC;IAC/CC,KAAK,EAAEhB,MAAM,CAACC;AAChB,GAAC,EACD,gDAAgD,CACjD,EACD,CACEW,qBAAqB,EACrB;AACEG,IAAAA,MAAM,EAAE,oCAAoC;AAC5CE,IAAAA,SAAS,EAAE,OAAO;AAClBC,IAAAA,UAAU,EAAE,eAAe;IAC3BF,KAAK,EAAEhB,MAAM,CAACG;AAChB,GAAC,EACD,8CAA8C,CAC/C,EACD,CACES,qBAAqB,EACrB;AACEG,IAAAA,MAAM,EAAE,8BAA8B;AACtCE,IAAAA,SAAS,EAAE,KAAK;AAChBD,IAAAA,KAAK,EAAE;AACLG,MAAAA,OAAO,EAAE,IAAI;AACbC,MAAAA,UAAU,EAAE,IAAI;AAChBC,MAAAA,KAAK,EAAE,IAAI;AACXC,MAAAA,YAAY,EAAE,IAAI;AAClBC,MAAAA,KAAK,EAAE,IAAI;AACXC,MAAAA,aAAa,EAAE;AACjB;GACD,EACD,8BAA8B,CAC/B,CACsB;AAEzB,EAAA,OAAOV,OAAO;AAChB;;;;"}
1
+ {"version":3,"file":"babel-macros.js","sources":["../src/babel-macros.ts"],"sourcesContent":["/**\n * Babel plugins that convert constants and expressions into [macroConditions](https://www.npmjs.com/package/@embroider/macros#the-macros)\n * so that they can be stripped from the code during the build process.\n *\n * This allows us to have great DX around common configuration patterns\n * while still being able to ship a small and fast library.\n *\n * Transforms\n *\n * - deprecation constants imported from `@warp-drive-mirror/build-config/deprecations`\n * - feature flags imported from `@warp-drive-mirror/build-config/canary-features`\n * - debug logging constants imported from `@warp-drive-mirror/build-config/debugging`\n * - environment constants imported from `@warp-drive-mirror/build-config/env`\n * - expressionts imported from `@warp-drive-mirror/build-config/macros`\n *\n * Addons and apps can use these plugins to match the code-stripping behaviors of\n * ***Warp*Drive**. This is useful when managing migrations for canary features\n * and deprecations.\n *\n * @module\n */\nimport * 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\ntype BabelPlugin = [string, Record<string, unknown>, string];\n\n/**\n * @returns an array of Babel plugins that can be used for code-stripping\n * based on the configuration supplied to `setConfig` and the current ENV.\n *\n * - deprecation constants imported from `@warp-drive-mirror/build-config/deprecations`\n * - feature flags imported from `@warp-drive-mirror/build-config/canary-features`\n * - debug logging constants imported from `@warp-drive-mirror/build-config/debugging`\n * - environment constants imported from `@warp-drive-mirror/build-config/env`\n * - expressionts imported from `@warp-drive-mirror/build-config/macros`\n */\nexport function macros(): BabelPlugin[] {\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 [\n TransformAsserts,\n {\n sources: ['@warp-drive-mirror/build-config/macros', '@warp-drive/core/build-config/macros'],\n },\n '@warp-drive/core/build-config/asserts-stripping',\n ],\n [\n TransformFeatures,\n {\n sources: ['@warp-drive-mirror/build-config/canary-features', '@warp-drive/core/build-config/canary-features'],\n flags: config.features,\n },\n '@warp-drive/core/build-config/canary-features-stripping',\n ],\n [\n TransformDeprecations,\n {\n sources: ['@warp-drive-mirror/build-config/deprecations', '@warp-drive/core/build-config/deprecations'],\n flags: config.deprecations,\n },\n '@warp-drive/core/build-config/deprecation-stripping',\n ],\n [\n TransformDebugLogging,\n {\n sources: ['@warp-drive-mirror/build-config/debugging', '@warp-drive/core/build-config/debugging'],\n configKey: 'debug',\n runtimeKey: 'activeLogging',\n flags: config.debug,\n },\n '@warp-drive/core/build-config/debugging-stripping',\n ],\n [\n TransformDebugLogging,\n {\n sources: ['@warp-drive-mirror/build-config/env', '@warp-drive/core/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/core/build-config/env',\n ],\n ] satisfies BabelPlugin[];\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","sources","flags","configKey","runtimeKey","TESTING","PRODUCTION","DEBUG","IS_RECORDING","IS_CI","SHOULD_RECORD"],"mappings":";;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAMA,MAAMA,QAAQ,GAAGC,MAAM,CAACC,IAAI,CAACC,gBAAgB,CAAc;AAC3D,MAAMC,QAAQ,GAAGH,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEF,gBAAgB,CAA6B;AAChFH,QAAQ,CAACM,OAAO,CAAEC,OAAO,IAAK;AAC5B,EAAA,IAAIC,YAAY,GAAGJ,QAAQ,CAACG,OAAO,CAAC;EACpC,IAAIC,YAAY,KAAK,IAAI,EAAE;AACzBJ,IAAAA,QAAQ,CAACG,OAAO,CAAC,GAAG,KAAK;AAC3B;AACF,CAAC,CAAC;AAEF,MAAME,MAAM,GAAG;AACbT,EAAAA,QAAQ,EAAEI,QAAQ;EAClBM,YAAY,EAAET,MAAM,CAACI,MAAM,CAAC,EAAE,EAAEM,oBAAoB,CAAC;EAC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AM,CAACG;AAChB,GAAC,EACD,mDAAmD,CACpD,EACD,CACES,qBAAqB,EACrB;AACEG,IAAAA,OAAO,EAAE,CAAC,8BAA8B,EAAE,mCAAmC,CAAC;AAC9EE,IAAAA,SAAS,EAAE,KAAK;AAChBD,IAAAA,KAAK,EAAE;AACLG,MAAAA,OAAO,EAAE,IAAI;AACbC,MAAAA,UAAU,EAAE,IAAI;AAChBC,MAAAA,KAAK,EAAE,IAAI;AACXC,MAAAA,YAAY,EAAE,IAAI;AAClBC,MAAAA,KAAK,EAAE,IAAI;AACXC,MAAAA,aAAa,EAAE;AACjB;GACD,EACD,mCAAmC,CACpC,CACsB;AAEzB,EAAA,OAAOV,OAAO;AAChB;;;;"}
@@ -63,12 +63,12 @@ function babelPluginTransformAsserts (babel) {
63
63
  visitor: {
64
64
  ImportDeclaration(path, state) {
65
65
  const importPath = path.node.source.value;
66
- if (importPath === '@warp-drive-mirror/build-config/macros') {
66
+ if (state.opts.sources.includes(importPath)) {
67
67
  const specifiers = path.get('specifiers');
68
68
  specifiers.forEach(specifier => {
69
69
  const name = specifier.node.imported.name;
70
70
  if (!Utils.has(name)) {
71
- throw new Error(`Unexpected import '${name}' imported from '@warp-drive-mirror/build-config/macros'`);
71
+ throw new Error(`Unexpected import '${name}' imported from '${importPath}'`);
72
72
  }
73
73
  const localBindingName = specifier.node.local.name;
74
74
  const binding = specifier.scope.getBinding(localBindingName);
@@ -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().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;AAAW,CAAC,GAAGC,OAAO,CAAC,mBAAmB,CAAC;AAEnD,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;;AAEjC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,SAASC,oBAAoBA,CAACC,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAE;EACnD,OAAOF,KAAK,CAACG,gBAAgB,CAC3BH,KAAK,CAACG,gBAAgB,CACpBH,KAAK,CAACG,gBAAgB,CACpBH,KAAK,CAACI,cAAc,CAACF,KAAK,CAACG,QAAQ,CAACC,MAAM,CAACL,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAChGD,KAAK,CAACO,UAAU,CAAC,WAAW,CAC9B,CAAC,EACDP,KAAK,CAACO,UAAU,CAAC,KAAK,CACxB,CAAC,EACDP,KAAK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IAAI;AAEhD,cAAA,IAAI,CAACN,CAAC,CAACuB,gBAAgB,CAACvC,sBAAsB,CAAC,EAAE;AAC/C,gBAAA,MAAM,IAAI+B,KAAK,CAAC,4BAA4B,CAAC;AAC/C;cAEA,MAAMS,aAAa,GAAG7B,kBAAkB,CAACK,CAAC,EAAEzB,OAAO,EAAEC,KAAK,EAAEQ,sBAAsB,CAAC;AACnFqC,cAAAA,CAAC,CAACC,UAAU,CAACG,WAAW,CAACD,aAAa,CAAC;AACzC,aAAC,CAAC;AACFZ,YAAAA,SAAS,CAACM,KAAK,CAACQ,gBAAgB,CAACV,gBAAgB,CAAC;YAClDJ,SAAS,CAACe,MAAM,EAAE;AACpB,WAAC,CAAC;UAEF,IAAIvB,IAAI,CAACM,GAAG,CAAC,YAAY,CAAC,CAACkB,MAAM,KAAK,CAAC,EAAE;YACvCxB,IAAI,CAACuB,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAACzB,IAAI,EAAE5B,KAAK,EAAE;QACnBA,KAAK,CAACG,QAAQ,GAAG,IAAIV,UAAU,CAAC+B,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
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 (state.opts.sources.includes(importPath)) {\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 '${importPath}'`);\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","opts","sources","includes","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;AAAW,CAAC,GAAGC,OAAO,CAAC,mBAAmB,CAAC;AAEnD,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;;AAEjC;AACA;AACA;;AAEA;;AAEA;AACA;AACA;;AAEA;AACA,SAASC,oBAAoBA,CAACC,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAE;EACnD,OAAOF,KAAK,CAACG,gBAAgB,CAC3BH,KAAK,CAACG,gBAAgB,CACpBH,KAAK,CAACG,gBAAgB,CACpBH,KAAK,CAACI,cAAc,CAACF,KAAK,CAACG,QAAQ,CAACC,MAAM,CAACL,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,CAAC,EAAE,EAAE,CAAC,EAChGD,KAAK,CAACO,UAAU,CAAC,WAAW,CAC9B,CAAC,EACDP,KAAK,CAACO,UAAU,CAAC,KAAK,CACxB,CAAC,EACDP,KAAK,CAACO,UAAU,CAAC,OAAO,CAC1B,CAAC;AACH;;AAEA;AACA,SAASC,wBAAwBA,CAACR,KAAK,EAAEC,OAAO,EAAEC,KAAK,EAAE;EACvD,OAAOF,KAAK,CAACI,cAAc,CAACF,KAAK,CAACG,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AAM,IAAIkC,KAAK,CAAC,4BAA4B,CAAC;AAC/C;cAEA,MAAMS,aAAa,GAAGhC,kBAAkB,CAACK,CAAC,EAAEzB,OAAO,EAAEC,KAAK,EAAEQ,sBAAsB,CAAC;AACnFwC,cAAAA,CAAC,CAACC,UAAU,CAACG,WAAW,CAACD,aAAa,CAAC;AACzC,aAAC,CAAC;AACFZ,YAAAA,SAAS,CAACM,KAAK,CAACQ,gBAAgB,CAACV,gBAAgB,CAAC;YAClDJ,SAAS,CAACe,MAAM,EAAE;AACpB,WAAC,CAAC;UAEF,IAAI1B,IAAI,CAACS,GAAG,CAAC,YAAY,CAAC,CAACkB,MAAM,KAAK,CAAC,EAAE;YACvC3B,IAAI,CAAC0B,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAAC5B,IAAI,EAAE5B,KAAK,EAAE;QACnBA,KAAK,CAACG,QAAQ,GAAG,IAAIV,UAAU,CAAC+B,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
@@ -17,12 +17,12 @@ function babelPluginTransformDeprecations (babel) {
17
17
  visitor: {
18
18
  ImportDeclaration(path, state) {
19
19
  const importPath = path.node.source.value;
20
- if (importPath === state.opts.source) {
20
+ if (state.opts.sources.includes(importPath)) {
21
21
  const specifiers = path.get('specifiers');
22
22
  specifiers.forEach(specifier => {
23
23
  let name = specifier.node.imported.name;
24
24
  if (!(name in state.opts.flags)) {
25
- throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);
25
+ throw new Error(`Unexpected flag ${name} imported from ${importPath}`);
26
26
  }
27
27
  let localBindingName = specifier.node.local.name;
28
28
  let binding = specifier.scope.getBinding(localBindingName);
@@ -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 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,QAAQ,KAAK,GAAG,EAAE;AAC1E,IAAA,OAAO,IAAI;AACb;AACA,EAAA,OAAO,KAAK;AACd;AAEe,yCAAA,EAAUC,KAAK,EAAE;EAC9B,MAAM;AAAEC,IAAAA,KAAK,EAAEC;AAAE,GAAC,GAAGF,KAAK;EAE1B,OAAO;AACLG,IAAAA,IAAI,EAAE,mBAAmB;AACzBC,IAAAA,OAAO,EAAE;AACPC,MAAAA,iBAAiBA,CAACC,IAAI,EAAEC,KAAK,EAAE;QAC7B,MAAMC,UAAU,GAAGF,IAAI,CAACV,IAAI,CAACa,MAAM,CAACC,KAAK;AAEzC,QAAA,IAAIF,UAAU,KAAKD,KAAK,CAACI,IAAI,CAACF,MAAM,EAAE;AACpC,UAAA,MAAMG,UAAU,GAAGN,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC;AACzCD,UAAAA,UAAU,CAACE,OAAO,CAAEC,SAAS,IAAK;YAChC,IAAIZ,IAAI,GAAGY,SAAS,CAACnB,IAAI,CAACoB,QAAQ,CAACb,IAAI;YACvC,IAAI,EAAEA,IAAI,IAAII,KAAK,CAACI,IAAI,CAACM,KAAK,CAAC,EAAE;AAC/B,cAAA,MAAM,IAAIC,KAAK,CAAC,CAAA,gBAAA,EAAmBf,IAAI,CAAA,eAAA,EAAkBI,KAAK,CAACI,IAAI,CAACF,MAAM,CAAA,CAAE,CAAC;AA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C,UAAU,CAACtC,IAAI,CACnB,CAAC;AAED,cAAA,MAAMuC,SAAS,GAAGf,eAAe,GAAGzB,CAAC,CAACyC,eAAe,CAAC,GAAG,EAAEP,SAAS,CAAC,GAAGA,SAAS;cACjF,MAAMQ,UAAU,GAAGb,uBAAuB;AACtC;AACA;AACA;cACAW,SAAS;AACT;AACA;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;AAClG9C,cAAAA,IAAI,CAACiD,WAAW,CAACD,UAAU,CAAC;AAC9B,aAAC,CAAC;AACF7B,YAAAA,SAAS,CAACO,KAAK,CAACwB,gBAAgB,CAAC3B,gBAAgB,CAAC;YAClDJ,SAAS,CAACgC,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAIzC,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAACmB,MAAM,KAAK,CAAC,EAAE;YACvC1B,IAAI,CAACyC,MAAM,EAAE;AACf;AACF;OACD;AAEDC,MAAAA,OAAOA,CAAC1C,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAACgC,QAAQ,GAAG,IAAIU,0BAAU,CAAC/C,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
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 (state.opts.sources.includes(importPath)) {\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 ${importPath}`);\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","sources","includes","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","unaryEx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ACT;AACA;AACA;AACA1C,cAAAA,CAAC,CAACsC,cAAc,CAACjC,KAAK,CAACkC,QAAQ,CAACC,MAAM,CAACf,CAAC,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,CAACiB,SAAS,CAAC,CAAC;AAClGhD,cAAAA,IAAI,CAACmD,WAAW,CAACD,UAAU,CAAC;AAC9B,aAAC,CAAC;AACF7B,YAAAA,SAAS,CAACO,KAAK,CAACwB,gBAAgB,CAAC3B,gBAAgB,CAAC;YAClDJ,SAAS,CAACgC,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAI3C,IAAI,CAACS,GAAG,CAAC,YAAY,CAAC,CAACmB,MAAM,KAAK,CAAC,EAAE;YACvC5B,IAAI,CAAC2C,MAAM,EAAE;AACf;AACF;OACD;AAEDC,MAAAA,OAAOA,CAAC5C,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAACkC,QAAQ,GAAG,IAAIU,0BAAU,CAACjD,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
@@ -23,12 +23,12 @@ function babelPluginTransformFeatures (babel) {
23
23
  visitor: {
24
24
  ImportDeclaration(path, state) {
25
25
  const importPath = path.node.source.value;
26
- if (importPath === state.opts.source) {
26
+ if (state.opts.sources.includes(importPath)) {
27
27
  const specifiers = path.get('specifiers');
28
28
  specifiers.forEach(specifier => {
29
29
  let name = specifier.node.imported.name;
30
30
  if (!(name in state.opts.flags)) {
31
- throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);
31
+ throw new Error(`Unexpected flag ${name} imported from ${importPath}`);
32
32
  }
33
33
  let localBindingName = specifier.node.local.name;
34
34
  let binding = specifier.scope.getBinding(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\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","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","parentPath","getConfig","memberExpression","callExpression","importer","import","identifier","replaceWith","unaryExpression","remov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SAAS,CAACsB,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAI/B,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAACyB,MAAM,KAAK,CAAC,EAAE;YACvChC,IAAI,CAAC+B,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAACjC,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAACwB,QAAQ,GAAG,IAAIS,0BAAU,CAACtC,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
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 (state.opts.sources.includes(importPath)) {\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 ${importPath}`);\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\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","includes","parentIsUnary","node","parent","type","operator","babel","types","t","name","visitor","ImportDeclaration","path","state","importPath","source","value","opts","sources","specifiers","get","forEach","specifier","imported","flags","Error","localBindingName","local","binding","scope","getBinding","referencePaths","p","negateStatement","parentPath","getConfig","memberExpression","callExpression","importer","import","identifier","replaceWith","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;AAC7F,MAAMC,OAAO,GAAGL,GAAG,CAACK,OAAO;AAEVA,OAAO,CAACC,QAAQ,CAAC,OAAO;AAEzC,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;AACb;AACA,EAAA,OAAO,KAAK;AACd;AAEe,qCAAA,EAAUC,KAAK,EAAE;EAC9B,MAAM;AAAEC,IAAAA,KAAK,EAAEC;AAAE,GAAC,GAAGF,KAAK;EAE1B,OAAO;AACLG,IAAAA,IAAI,EAAE,eAAe;AAAE;AACvBC,IAAAA,OAAO,EAAE;AACPC,MAAAA,iBAAiBA,CAACC,IAAI,EAAEC,KAAK,EAAE;QAC7B,MAAMC,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C,EACDhC,CAAC,CAACgC,UAAU,CAAC,UAAU,CACzB,CAAC,EACDhC,CAAC,CAACgC,UAAU,CAAC/B,IAAI,CACnB,CAAC;AACDP,cAAAA,IAAI,CAACuC,WAAW;AACd;AACA;AACA;AACAjC,cAAAA,CAAC,CAAC6B,cAAc,CAACxB,KAAK,CAACyB,QAAQ,CAACC,MAAM,CAACP,CAAC,EAAE,mBAAmB,EAAE,gBAAgB,CAAC,EAAE,CAChFC,eAAe,GAAGzB,CAAC,CAACkC,eAAe,CAAC,GAAG,EAAEP,SAAS,CAAC,GAAGA,SAAS,CAChE,CACH,CAAC;AACH,aAAC,CAAC;AACFb,YAAAA,SAAS,CAACO,KAAK,CAACc,gBAAgB,CAACjB,gBAAgB,CAAC;YAClDJ,SAAS,CAACsB,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAIhC,IAAI,CAACQ,GAAG,CAAC,YAAY,CAAC,CAACyB,MAAM,KAAK,CAAC,EAAE;YACvCjC,IAAI,CAACgC,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAAClC,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAACyB,QAAQ,GAAG,IAAIS,0BAAU,CAACvC,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
@@ -18,12 +18,12 @@ function babelPluginTransformLogging (babel) {
18
18
  visitor: {
19
19
  ImportDeclaration(path, state) {
20
20
  const importPath = path.node.source.value;
21
- if (importPath === state.opts.source) {
21
+ if (state.opts.sources.includes(importPath)) {
22
22
  const specifiers = path.get('specifiers');
23
23
  specifiers.forEach(specifier => {
24
24
  let name = specifier.node.imported.name;
25
25
  if (!(name in state.opts.flags)) {
26
- throw new Error(`Unexpected flag ${name} imported from ${state.opts.source}`);
26
+ throw new Error(`Unexpected flag ${name} imported from ${importPath}`);
27
27
  }
28
28
  let localBindingName = specifier.node.local.name;
29
29
  let binding = specifier.scope.getBinding(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 const enableRuntimeActivation = Boolean(state.opts.runtimeKey);\n const strippableKey = enableRuntimeActivation ? state.opts.runtimeKey : state.opts.configKey;\n\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(strippableKey)\n ),\n t.identifier(name)\n );\n\n node.replaceWith(\n // if (LOG_FOO) {\n // // ...\n // }\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO)) {\n // // ...\n // }\n t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [\n negateStatement ? t.unaryExpression('!', getConfig) : getConfig,\n ])\n );\n\n if (enableRuntimeActivation) {\n // we do not yet support arbitrary runtime activation locations,\n // the only supported locations are `if (LOG)` style statements, no\n // ternaries or other more complex expressions\n const parentIfStatement = node.parentPath.type === 'IfStatement' ? node.parentPath : null;\n if (!parentIfStatement) {\n throw new Error(\n `Runtime activation of logging flags is only supported in if statements, but found node '${node.parentPath.type}'`\n );\n }\n\n // if (LOG_FOO) {\n // // ...\n // }\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').activeLogging.LOG_FOO)) {\n // if (getGlobalConfig('WarpDriveMirror').debug.LOG_FOO || globalThis.getWarpDriveRuntimeConfig().debug.LOG_FOO) {\n // // ...\n // }\n // }\n //\n // the outer-if is generated by the node-replace above. The inner if is generated here.\n const originalBody = parentIfStatement.node.consequent;\n\n // getGlobalConfig('WarpDriveMirror').debug.LOG_FOO\n const getActualConfig = 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\n // globalThis.getWarpDriveRuntimeConfig().debug.LOG_FOO\n const getRuntimeConfig = t.memberExpression(\n t.memberExpression(\n t.callExpression(\n t.memberExpression(t.identifier('globalThis'), t.identifier('getWarpDriveRuntimeConfig')),\n []\n ),\n t.identifier(state.opts.configKey)\n ),\n t.identifier(name)\n );\n\n // <getActualConfig> || <getRuntimeConfig>\n const ifExp = t.logicalExpression('||', getActualConfig, getRuntimeConfig);\n\n // if (<negateStatement>(<getActualConfig> || <getRuntimeConfig>)) <originalBody>\n const innerIfStatement = t.ifStatement(\n negateStatement ? t.unaryExpression('!', ifExp) : ifExp,\n originalBody\n );\n\n // replace the original body with the new if statement\n parentIfStatement.node.consequent = t.blockStatement([innerIfStatement]);\n } else {\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","enableRuntimeActivation","Boolean","runtimeKey","strippableKey","configKey","referencePaths","p","negateStatement","parentPath","getConfig","memberExpression","callExpression","importer","import","identifier","replaceWith","unaryExpression","parentIfStatement","originalBody","consequent","getActualConfig","getRuntimeConfig","ifExp","logicalExpression","innerIfStatement","ifStatement","blockStatement","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;AACb;AACA,EAAA,OAAO,KAAK;AACd;AAEe,oCAAA,EAAUC,KAAK,EAAE;EAC9B,MAAM;AAAEC,IAAAA,KAAK,EAAEC;AAAE,GAAC,GAAGF,KAAK;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;AAEzC,QAAA,IAAIF,UAAU,KAAKD,KAAK,CAACI,IAAI,CAACF,MAAM,EAAE;AACpC,UAAA,MAAMG,UAAU,GAAGN,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC;AACzCD,UAAAA,UAAU,CAACE,OAAO,CAAEC,SAAS,IAAK;YAChC,IAAIZ,IAAI,GAAGY,SAAS,CAACnB,IAAI,CAACoB,QAAQ,CAACb,IAAI;YACvC,IAAI,EAAEA,IAAI,IAAII,KAAK,CAACI,IAAI,CAACM,KAAK,CAAC,EAAE;AAC/B,cAAA,MAAM,IAAIC,KAAK,CAAC,CAAA,gBAAA,EAAmBf,IAAI,CAAA,eAAA,EAAkBI,KAAK,CAACI,IAAI,CAACF,MAAM,CAAA,CAAE,CAAC;AAC/E;YACA,IAAIU,gBAAgB,GAAGJ,SAA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/B,KAAK,CAACI,IAAI,CAACiB,SAAS,CACnC,CAAC,EACD1B,CAAC,CAACoC,UAAU,CAACnC,IAAI,CACnB,CAAC;;AAED;gBACA,MAAM2C,KAAK,GAAG5C,CAAC,CAAC6C,iBAAiB,CAAC,IAAI,EAAEH,eAAe,EAAEC,gBAAgB,CAAC;;AAE1E;gBACA,MAAMG,gBAAgB,GAAG9C,CAAC,CAAC+C,WAAW,CACpClB,eAAe,GAAG7B,CAAC,CAACsC,eAAe,CAAC,GAAG,EAAEM,KAAK,CAAC,GAAGA,KAAK,EACvDJ,YACF,CAAC;;AAED;AACAD,gBAAAA,iBAAiB,CAAC7C,IAAI,CAAC+C,UAAU,GAAGzC,CAAC,CAACgD,cAAc,CAAC,CAACF,gBAAgB,CAAC,CAAC;AAC1E;AAEF,aAAC,CAAC;AACFjC,YAAAA,SAAS,CAACO,KAAK,CAAC6B,gBAAgB,CAAChC,gBAAgB,CAAC;YAClDJ,SAAS,CAACqC,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAI9C,IAAI,CAACO,GAAG,CAAC,YAAY,CAAC,CAACwC,MAAM,KAAK,CAAC,EAAE;YACvC/C,IAAI,CAAC8C,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAAChD,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAAC6B,QAAQ,GAAG,IAAImB,0BAAU,CAACrD,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
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 (state.opts.sources.includes(importPath)) {\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 ${importPath}`);\n }\n let localBindingName = specifier.node.local.name;\n let binding = specifier.scope.getBinding(localBindingName);\n const enableRuntimeActivation = Boolean(state.opts.runtimeKey);\n const strippableKey = enableRuntimeActivation ? state.opts.runtimeKey : state.opts.configKey;\n\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(strippableKey)\n ),\n t.identifier(name)\n );\n\n node.replaceWith(\n // if (LOG_FOO) {\n // // ...\n // }\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').debug.LOG_FOO)) {\n // // ...\n // }\n t.callExpression(state.importer.import(p, '@embroider/macros', 'macroCondition'), [\n negateStatement ? t.unaryExpression('!', getConfig) : getConfig,\n ])\n );\n\n if (enableRuntimeActivation) {\n // we do not yet support arbitrary runtime activation locations,\n // the only supported locations are `if (LOG)` style statements, no\n // ternaries or other more complex expressions\n const parentIfStatement = node.parentPath.type === 'IfStatement' ? node.parentPath : null;\n if (!parentIfStatement) {\n throw new Error(\n `Runtime activation of logging flags is only supported in if statements, but found node '${node.parentPath.type}'`\n );\n }\n\n // if (LOG_FOO) {\n // // ...\n // }\n // =>\n // if (macroCondition(getGlobalConfig('WarpDriveMirror').activeLogging.LOG_FOO)) {\n // if (getGlobalConfig('WarpDriveMirror').debug.LOG_FOO || globalThis.getWarpDriveRuntimeConfig().debug.LOG_FOO) {\n // // ...\n // }\n // }\n //\n // the outer-if is generated by the node-replace above. The inner if is generated here.\n const originalBody = parentIfStatement.node.consequent;\n\n // getGlobalConfig('WarpDriveMirror').debug.LOG_FOO\n const getActualConfig = 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\n // globalThis.getWarpDriveRuntimeConfig().debug.LOG_FOO\n const getRuntimeConfig = t.memberExpression(\n t.memberExpression(\n t.callExpression(\n t.memberExpression(t.identifier('globalThis'), t.identifier('getWarpDriveRuntimeConfig')),\n []\n ),\n t.identifier(state.opts.configKey)\n ),\n t.identifier(name)\n );\n\n // <getActualConfig> || <getRuntimeConfig>\n const ifExp = t.logicalExpression('||', getActualConfig, getRuntimeConfig);\n\n // if (<negateStatement>(<getActualConfig> || <getRuntimeConfig>)) <originalBody>\n const innerIfStatement = t.ifStatement(\n negateStatement ? t.unaryExpression('!', ifExp) : ifExp,\n originalBody\n );\n\n // replace the original body with the new if statement\n parentIfStatement.node.consequent = t.blockStatement([innerIfStatement]);\n } else {\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","sources","includes","specifiers","get","forEach","specifier","imported","flags","Error","localBindingName","local","binding","scope","getBinding","enableRuntimeActivation","Boolean","runtimeKey","strippableKey","configKey","referencePaths","p","negateStatement","parentPath","getConfig","memberExpression","callExpression","importer","import","identifier","replaceWith","unaryExpression","parentIfStatement","originalBody","consequent","getActualConfig","getRuntimeConfig","ifExp","logicalExpression","innerIfStatement","ifStatement","blockStatement","removeOwnBinding","remove","length","Program","ImportUtil"],"mappings":";;;;AAEA,SAASA,aAAaA,CAACC,IAAI,EAAE;AAC3B,EAAA,IAAIA,IAAI,CAACC,MAAM,CAACC,IAAI,K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G,EAAEM,KAAK,CAAC,GAAGA,KAAK,EACvDJ,YACF,CAAC;;AAED;AACAD,gBAAAA,iBAAiB,CAAC/C,IAAI,CAACiD,UAAU,GAAG3C,CAAC,CAACkD,cAAc,CAAC,CAACF,gBAAgB,CAAC,CAAC;AAC1E;AAEF,aAAC,CAAC;AACFjC,YAAAA,SAAS,CAACO,KAAK,CAAC6B,gBAAgB,CAAChC,gBAAgB,CAAC;YAClDJ,SAAS,CAACqC,MAAM,EAAE;AACpB,WAAC,CAAC;UACF,IAAIhD,IAAI,CAACS,GAAG,CAAC,YAAY,CAAC,CAACwC,MAAM,KAAK,CAAC,EAAE;YACvCjD,IAAI,CAACgD,MAAM,EAAE;AACf;AACF;OACD;AAEDE,MAAAA,OAAOA,CAAClD,IAAI,EAAEC,KAAK,EAAE;QACnBA,KAAK,CAAC+B,QAAQ,GAAG,IAAImB,0BAAU,CAACvD,CAAC,EAAEI,IAAI,CAAC;AAC1C;AACF;GACD;AACH;;;;"}
@@ -0,0 +1,170 @@
1
+ /**
2
+ *
3
+ * # Canary Features <Badge type="warning" text="requires canary" />
4
+ *
5
+ * ***Warp*Drive** allows users to test upcoming features that are implemented
6
+ * but not yet activated in canary builds.
7
+ *
8
+ * Typically these features represent work that carries higher risk of breaking
9
+ * changes, or are not yet fully ready for production use.
10
+ *
11
+ * Such features have their implementations guarded by a "feature flag", and the
12
+ * flag is only activated once the core-data team is prepared to ship the work
13
+ * in a canary release, beginning the process of it landing in a stable release.
14
+ *
15
+ * ### Installing Canary
16
+ *
17
+ * ::: warning To test a feature guarded behind a flag, you MUST be using a canary build.
18
+ * :::
19
+ *
20
+ * Canary builds are published to `npm` and can be installed using a precise tag
21
+ * (such as `@warp-drive/core@5.6.0-alpha.1`) or by installing the latest dist-tag
22
+ * published to the `canary` channel.
23
+ *
24
+ * Because ***Warp*Drive** packages operate on a strict lockstep policy with each other,
25
+ * you must install the matching canary version of all ***Warp*Drive** packages.
26
+ *
27
+ * Below is an example of installing the latest canary version of all the primary
28
+ * packages that are part of the ***Warp*Drive** project. Add/remove packages from
29
+ * this list to match your project.
30
+ *
31
+ * ::: code-group
32
+ *
33
+ * ```sh [pnpm]
34
+ * pnpm add -E @ember-data-mirror/store@canary \
35
+ * @ember-data-mirror/json-api@canary \
36
+ * @ember-data-mirror/debug@canary \
37
+ * @ember-data-mirror/graph@canary \
38
+ * @ember-data-mirror/request@canary \
39
+ * @ember-data-mirror/request-utils@canary \
40
+ * @warp-drive-mirror/schema-record@canary \
41
+ * @warp-drive-mirror/build-config@canary \
42
+ * @warp-drive-mirror/core-types@canary;
43
+ * ```
44
+ *
45
+ * ```sh [npm]
46
+ * npm add -E @ember-data-mirror/store@canary \
47
+ * @ember-data-mirror/json-api@canary \
48
+ * @ember-data-mirror/debug@canary \
49
+ * @ember-data-mirror/graph@canary \
50
+ * @ember-data-mirror/request@canary \
51
+ * @ember-data-mirror/request-utils@canary \
52
+ * @warp-drive-mirror/schema-record@canary \
53
+ * @warp-drive-mirror/build-config@canary \
54
+ * @warp-drive-mirror/core-types@canary;
55
+ * ```
56
+ *
57
+ * ```sh [yarn]
58
+ * yarn add -E @ember-data-mirror/store@canary \
59
+ * @ember-data-mirror/json-api@canary \
60
+ * @ember-data-mirror/debug@canary \
61
+ * @ember-data-mirror/graph@canary \
62
+ * @ember-data-mirror/request@canary \
63
+ * @ember-data-mirror/request-utils@canary \
64
+ * @warp-drive-mirror/schema-record@canary \
65
+ * @warp-drive-mirror/build-config@canary \
66
+ * @warp-drive-mirror/core-types@canary;
67
+ * ```
68
+ *
69
+ * ```sh [bun]
70
+ * bun add --exact @ember-data-mirror/store@canary \
71
+ * @ember-data-mirror/json-api@canary \
72
+ * @ember-data-mirror/debug@canary \
73
+ * @ember-data-mirror/graph@canary \
74
+ * @ember-data-mirror/request@canary \
75
+ * @ember-data-mirror/request-utils@canary \
76
+ * @warp-drive-mirror/schema-record@canary \
77
+ * @warp-drive-mirror/build-config@canary \
78
+ * @warp-drive-mirror/core-types@canary;
79
+ * ```
80
+ *
81
+ * :::
82
+ *
83
+ * ### Activating a Feature
84
+ *
85
+ * Once you have installed canary, feature-flags can be activated at build-time
86
+ *
87
+ * ```ts
88
+ * setConfig(app, __dirname, {
89
+ * features: {
90
+ * FEATURE_A: false, // utilize existing behavior
91
+ * FEATURE_B: true // utilize the new behavior
92
+ * }
93
+ * })
94
+ * ```
95
+ *
96
+ * by setting an environment variable:
97
+ *
98
+ * ```sh
99
+ * # Activate a single flag
100
+ * export WARP_DRIVE_FEATURE_OVERRIDE=SOME_FLAG;
101
+ *
102
+ * # Activate multiple flags by separating with commas
103
+ * export WARP_DRIVE_FEATURE_OVERRIDE=SOME_FLAG,OTHER_FLAG;
104
+ *
105
+ * # Activate all flags
106
+ * export WARP_DRIVE_FEATURE_OVERRIDE=ENABLE_ALL_OPTIONAL;
107
+ * ```
108
+ *
109
+ * ::: warning To test a feature guarded behind a flag, you MUST be running a development build.
110
+ * :::
111
+ *
112
+ *
113
+ * ### Preparing a Project to use a Canary Feature
114
+ *
115
+ * For most projects and features, simple version detection should be enough.
116
+ *
117
+ * Using the provided version compatibility helpers from [embroider-macros](https://github.com/embroider-build/embroider/tree/main/packages/macros#readme)
118
+ * the following can be done:
119
+ *
120
+ * ```js
121
+ * if (macroCondition(dependencySatisfies('@ember-data-mirror/store', '5.0'))) {
122
+ * // do thing
123
+ * }
124
+ * ```
125
+ *
126
+ * For more complex projects and migrations, configure [@warp-drive-mirror/build-config/babel-macros](./babel-macros)
127
+ *
128
+ * The current list of features used at build time for canary releases is defined below.
129
+ *
130
+ * ::: tip 💡 If empty there are no features currently gated by feature flags.
131
+ * :::
132
+ *
133
+ * The valid values are:
134
+ *
135
+ * - `true` | The feature is **enabled** at all times, and cannot be disabled.
136
+ * - `false` | The feature is **disabled** at all times, and cannot be enabled.
137
+ * - `null` | The feature is **disabled by default**, but can be enabled via configuration.
138
+ *
139
+ * @module
140
+ * @public
141
+ */
142
+
143
+ /**
144
+ * We use this for some tests etc.
145
+ *
146
+ * @internal
147
+ */
148
+ const SAMPLE_FEATURE_FLAG = null;
149
+
150
+ /**
151
+ * This upcoming feature adds a validation step to payloads received
152
+ * by the JSONAPICache implementation.
153
+ *
154
+ * When a request completes and the result is given to the cache via
155
+ * `cache.put`, the cache will validate the payload against registered
156
+ * schemas as well as the JSON:API spec.
157
+ *
158
+ * @since 5.4
159
+ * @public
160
+ */
161
+ const JSON_API_CACHE_VALIDATION_ERRORS = false;
162
+
163
+ const CURRENT_FEATURES = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
164
+ __proto__: null,
165
+ JSON_API_CACHE_VALIDATION_ERRORS,
166
+ SAMPLE_FEATURE_FLAG
167
+ }, Symbol.toStringTag, { value: 'Module' }));
168
+
169
+ export { CURRENT_FEATURES as C, JSON_API_CACHE_VALIDATION_ERRORS as J, SAMPLE_FEATURE_FLAG as S };
170
+ //# sourceMappingURL=canary-features-DF5hbs2w.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"canary-features-DF5hbs2w.js","sources":["../src/canary-features.ts"],"sourcesContent":["/**\n *\n * # Canary Features <Badge type=\"warning\" text=\"requires canary\" />\n *\n * ***Warp*Drive** allows users to test upcoming features that are implemented\n * but not yet activated in canary builds.\n *\n * Typically these features represent work that carries higher risk of breaking\n * changes, or are not yet fully ready for production use.\n *\n * Such features have their implementations guarded by a \"feature flag\", and the\n * flag is only activated once the core-data team is prepared to ship the work\n * in a canary release, beginning the process of it landing in a stable release.\n *\n * ### Installing Canary\n *\n * ::: warning To test a feature guarded behind a flag, you MUST be using a canary build.\n * :::\n *\n * Canary builds are published to `npm` and can be installed using a precise tag\n * (such as `@warp-drive/core@5.6.0-alpha.1`) or by installing the latest dist-tag\n * published to the `canary` channel.\n *\n * Because ***Warp*Drive** packages operate on a strict lockstep policy with each other,\n * you must install the matching canary version of all ***Warp*Drive** packages.\n *\n * Below is an example of installing the latest canary version of all the primary\n * packages that are part of the ***Warp*Drive** project. Add/remove packages from\n * this list to match your project.\n *\n * ::: code-group\n *\n * ```sh [pnpm]\n * pnpm add -E @ember-data-mirror/store@canary \\\n * @ember-data-mirror/json-api@canary \\\n * @ember-data-mirror/debug@canary \\\n * @ember-data-mirror/graph@canary \\\n * @ember-data-mirror/request@canary \\\n * @ember-data-mirror/request-utils@canary \\\n * @warp-drive-mirror/schema-record@canary \\\n * @warp-drive-mirror/build-config@canary \\\n * @warp-drive-mirror/core-types@canary;\n * ```\n *\n * ```sh [npm]\n * npm add -E @ember-data-mirror/store@canary \\\n * @ember-data-mirror/json-api@canary \\\n * @ember-data-mirror/debug@canary \\\n * @ember-data-mirror/graph@canary \\\n * @ember-data-mirror/request@canary \\\n * @ember-data-mirror/request-utils@canary \\\n * @warp-drive-mirror/schema-record@canary \\\n * @warp-drive-mirror/build-config@canary \\\n * @warp-drive-mirror/core-types@canary;\n * ```\n *\n * ```sh [yarn]\n * yarn add -E @ember-data-mirror/store@canary \\\n * @ember-data-mirror/json-api@canary \\\n * @ember-data-mirror/debug@canary \\\n * @ember-data-mirror/graph@canary \\\n * @ember-data-mirror/request@canary \\\n * @ember-data-mirror/request-utils@canary \\\n * @warp-drive-mirror/schema-record@canary \\\n * @warp-drive-mirror/build-config@canary \\\n * @warp-drive-mirror/core-types@canary;\n * ```\n *\n * ```sh [bun]\n * bun add --exact @ember-data-mirror/store@canary \\\n * @ember-data-mirror/json-api@canary \\\n * @ember-data-mirror/debug@canary \\\n * @ember-data-mirror/graph@canary \\\n * @ember-data-mirror/request@canary \\\n * @ember-data-mirror/request-utils@canary \\\n * @warp-drive-mirror/schema-record@canary \\\n * @warp-drive-mirror/build-config@canary \\\n * @warp-drive-mirror/core-types@canary;\n * ```\n *\n * :::\n *\n * ### Activating a Feature\n *\n * Once you have installed canary, feature-flags can be activated at build-time\n *\n * ```ts\n * setConfig(app, __dirname, {\n * features: {\n * FEATURE_A: false, // utilize existing behavior\n * FEATURE_B: true // utilize the new behavior\n * }\n * })\n * ```\n *\n * by setting an environment variable:\n *\n * ```sh\n * # Activate a single flag\n * export WARP_DRIVE_FEATURE_OVERRIDE=SOME_FLAG;\n *\n * # Activate multiple flags by separating with commas\n * export WARP_DRIVE_FEATURE_OVERRIDE=SOME_FLAG,OTHER_FLAG;\n *\n * # Activate all flags\n * export WARP_DRIVE_FEATURE_OVERRIDE=ENABLE_ALL_OPTIONAL;\n * ```\n *\n * ::: warning To test a feature guarded behind a flag, you MUST be running a development build.\n * :::\n *\n *\n * ### Preparing a Project to use a Canary Feature\n *\n * For most projects and features, simple version detection should be enough.\n *\n * Using the provided version compatibility helpers from [embroider-macros](https://github.com/embroider-build/embroider/tree/main/packages/macros#readme)\n * the following can be done:\n *\n * ```js\n * if (macroCondition(dependencySatisfies('@ember-data-mirror/store', '5.0'))) {\n * // do thing\n * }\n * ```\n *\n * For more complex projects and migrations, configure [@warp-drive-mirror/build-config/babel-macros](./babel-macros)\n *\n * The current list of features used at build time for canary releases is defined below.\n *\n * ::: tip 💡 If empty there are no features currently gated by feature flags.\n * :::\n *\n * The valid values are:\n *\n * - `true` | The feature is **enabled** at all times, and cannot be disabled.\n * - `false` | The feature is **disabled** at all times, and cannot be enabled.\n * - `null` | The feature is **disabled by default**, but can be enabled via configuration.\n *\n * @module\n * @public\n */\n\n/**\n * We use this for some tests etc.\n *\n * @internal\n */\nexport const SAMPLE_FEATURE_FLAG: boolean | null = null;\n\n/**\n * This upcoming feature adds a validation step to payloads received\n * by the JSONAPICache implementation.\n *\n * When a request completes and the result is given to the cache via\n * `cache.put`, the cache will validate the payload against registered\n * schemas as well as the JSON:API spec.\n *\n * @since 5.4\n * @public\n */\nexport const JSON_API_CACHE_VALIDATION_ERRORS: boolean | null = false;\n"],"names":["SAMPLE_FEATURE_FLAG","JSON_API_CACHE_VALIDATION_ERRORS"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACO,MAAMA,mBAAmC,GAAG;;AAEnD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,gCAAgD,GAAG;;;;;;;;;;"}
@@ -1,2 +1,2 @@
1
- export { J as JSON_API_CACHE_VALIDATION_ERRORS, S as SAMPLE_FEATURE_FLAG } from './canary-features-D1wplYmb.js';
1
+ export { J as JSON_API_CACHE_VALIDATION_ERRORS, S as SAMPLE_FEATURE_FLAG } from './canary-features-DF5hbs2w.js';
2
2
  //# sourceMappingURL=canary-features.js.map