@embroider/compat 4.0.0-alpha.5 → 4.0.0-alpha.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/compat",
3
- "version": "4.0.0-alpha.5",
3
+ "version": "4.0.0-alpha.7",
4
4
  "private": false,
5
5
  "description": "Backward compatibility layer for the Embroider build system.",
6
6
  "repository": {
@@ -68,7 +68,7 @@
68
68
  "tree-sync": "^2.1.0",
69
69
  "typescript-memoize": "^1.0.1",
70
70
  "walk-sync": "^3.0.0",
71
- "@embroider/macros": "1.17.0-alpha.4"
71
+ "@embroider/macros": "1.17.0-alpha.5"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@glimmer/syntax": "^0.84.3",
@@ -91,12 +91,12 @@
91
91
  "ember-engines": "^0.8.19",
92
92
  "scenario-tester": "^4.0.0",
93
93
  "typescript": "^5.4.5",
94
- "@embroider/core": "^4.0.0-alpha.5",
94
+ "@embroider/core": "^4.0.0-alpha.6",
95
95
  "@embroider/sample-transforms": "0.0.0",
96
96
  "@embroider/test-support": "0.36.0"
97
97
  },
98
98
  "peerDependencies": {
99
- "@embroider/core": "^4.0.0-alpha.5"
99
+ "@embroider/core": "^4.0.0-alpha.6"
100
100
  },
101
101
  "engines": {
102
102
  "node": "12.* || 14.* || >= 16"
package/src/babel.js CHANGED
@@ -1,7 +1,4 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.pluginsFromV1Addons = pluginsFromV1Addons;
7
4
  exports.transformsFromV1Addons = transformsFromV1Addons;
@@ -15,26 +12,19 @@ exports.templateCompatSupport = templateCompatSupport;
15
12
  const fs_1 = require("fs");
16
13
  const core_1 = require("@embroider/core");
17
14
  const path_1 = require("path");
18
- const macros_config_1 = __importDefault(require("@embroider/macros/src/macros-config"));
15
+ const babel_1 = require("@embroider/macros/babel");
19
16
  function loadCompatConfig() {
20
17
  let compatFile = (0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(process.cwd()), '_babel_compat_.js');
21
18
  if ((0, fs_1.existsSync)(compatFile)) {
22
19
  // eslint-disable-next-line @typescript-eslint/no-require-imports
23
20
  return require(compatFile);
24
21
  }
25
- let macros = macros_config_1.default.for({}, process.cwd());
26
- let { plugins: templateMacros, setConfig } = macros_config_1.default.transforms();
27
- setConfig(macros);
28
- if (process.env.NODE_ENV === 'development') {
29
- macros.enablePackageDevelopment(process.cwd());
30
- macros.enableRuntimeMode();
31
- }
32
- macros.finalize();
22
+ let macros = (0, babel_1.buildMacros)();
33
23
  return {
34
24
  plugins: [],
35
25
  templateTransforms: [],
36
- babelMacros: macros.babelPluginConfig(),
37
- templateMacros: templateMacros,
26
+ babelMacros: macros.babelMacros,
27
+ templateMacros: macros.templateMacros,
38
28
  };
39
29
  }
40
30
  const resolverLoader = new core_1.ResolverLoader(process.cwd());
package/src/babel.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"babel.js","sourceRoot":"","sources":["babel.ts"],"names":[],"mappings":";;;;;AA4CA,kDAGC;AAED,wDAGC;AAED,4CAOC;AAED,wCAGC;AAED,kCAGC;AAED,wCAyCC;AAED,gDAkCC;AAED,gDAEC;AAED,sDAEC;AA7JD,2BAAgC;AAChC,0CAKyB;AACzB,+BAA4B;AAG5B,wFAA+D;AAS/D,SAAS,gBAAgB;IACvB,IAAI,UAAU,GAAG,IAAA,WAAI,EAAC,IAAA,gCAAyB,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACrF,IAAI,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,iEAAiE;QACjE,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;IACD,IAAI,MAAM,GAAG,uBAAY,C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EAAwE;QACxE,kBAAkB;QAClB,kBAAkB,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;QAEvC,oEAAoE;QACpE,wEAAwE;QACxE,sEAAsE;QACtE,YAAY,EAAE,IAAI;KACnB,CAAC;IACF,OAAO,CAAC,mCAA4B,EAAE,iBAAiB,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,kBAAkB;IAChC,OAAO,CAAC,GAAG,WAAW,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,kBAAkB,EAAE,EAAE,GAAG,mBAAmB,EAAE,CAAC,CAAC;AACjG,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO,CAAC,GAAG,sBAAsB,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import type { PluginItem } from '@babel/core';\nimport { existsSync } from 'fs';\nimport {\n locateEmbroiderWorkingDir,\n ResolverLoader,\n templateColocationPluginPath,\n type TemplateColocationPluginOptions,\n} from '@embroider/core';\nimport { join } from 'path';\nimport type { Transform } from 'babel-plugin-ember-template-compilation';\nimport type { Options as ResolverTransformOptions } from './resolver-transform';\nimport MacrosConfig from '@embroider/macros/src/macros-config';\n\nexport interface CompatBabelState {\n plugins: PluginItem[];\n templateTransforms: Transform[];\n babelMacros: PluginItem[];\n templateMacros: Transform[];\n}\n\nfunction loadCompatConfig(): CompatBabelState {\n let compatFile = join(locateEmbroiderWorkingDir(process.cwd()), '_babel_compat_.js');\n if (existsSync(compatFile)) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(compatFile);\n }\n let macros = MacrosConfig.for({}, process.cwd());\n let { plugins: templateMacros, setConfig } = MacrosConfig.transforms();\n setConfig(macros);\n if (process.env.NODE_ENV === 'development') {\n macros.enablePackageDevelopment(process.cwd());\n macros.enableRuntimeMode();\n }\n macros.finalize();\n return {\n plugins: [],\n templateTransforms: [],\n babelMacros: macros.babelPluginConfig(),\n templateMacros: templateMacros as any,\n };\n}\n\nconst resolverLoader = new ResolverLoader(process.cwd());\n\nexport function pluginsFromV1Addons() {\n let config = loadCompatConfig();\n return config.plugins;\n}\n\nexport function transformsFromV1Addons() {\n let config = loadCompatConfig();\n return config.templateTransforms;\n}\n\nexport function looseModeSupport(): Transform {\n const { resolver } = resolverLoader;\n let opts: ResolverTransformOptions = {\n appRoot: resolver.options.appRoot,\n emberVersion: resolver.options.emberVersion,\n };\n return [require.resolve('./resolver-transform'), opts];\n}\n\nexport function templateMacros() {\n let config = loadCompatConfig();\n return config.templateMacros;\n}\n\nexport function babelMacros() {\n let config = loadCompatConfig();\n return config.babelMacros;\n}\n\nexport function oldDebugMacros(): PluginItem[] {\n let debugMacros = require.resolve('babel-plugin-debug-macros');\n return [\n [\n debugMacros,\n {\n flags: [\n {\n source: '@glimmer/env',\n flags: {\n DEBUG: true,\n CI: false,\n },\n },\n ],\n debugTools: {\n isDebug: true,\n source: '@ember/debug',\n assertPredicateIndex: 1,\n },\n externalizeHelpers: {\n module: '@ember/debug',\n },\n },\n '@ember/debug stripping',\n ],\n [\n debugMacros,\n {\n externalizeHelpers: {\n module: '@ember/application/deprecations',\n },\n debugTools: {\n isDebug: true,\n source: '@ember/application/deprecations',\n assertPredicateIndex: 1,\n },\n },\n '@ember/application/deprecations stripping',\n ],\n ];\n}\n\nexport function templateColocation(): PluginItem {\n let colocationOptions: TemplateColocationPluginOptions = {\n appRoot: resolverLoader.resolver.options.appRoot,\n\n // This extra weirdness is a compromise in favor of build performance.\n //\n // 1. When auto-upgrading an addon from v1 to v2, we definitely want to\n // run any custom AST transforms in stage1.\n //\n // 2. In general case, AST transforms are allowed to manipulate Javascript\n // scope. This means that running transforms -- even when we're doing\n // source-to-source compilation that emits handlebars and not wire\n // format -- implies changing .hbs files into .js files.\n //\n // 3. So stage1 may need to rewrite .hbs to .hbs.js (to avoid colliding\n // with an existing co-located .js file).\n //\n // 4. But stage1 doesn't necessarily want to run babel over the\n // corresponding JS file. Most of the time, that's just an\n // unnecessarily expensive second parse. (We only run it in stage1 to\n // eliminate an addon's custom babel plugins, and many addons don't\n // have any.)\n //\n // 5. Therefore, the work of template-colocation gets defered until here,\n // and it may see co-located templates named `.hbs.js` instead of the\n // usual `.hbs.\n templateExtensions: ['.hbs', '.hbs.js'],\n\n // All of the above only applies to auto-upgraded packages that were\n // authored in v1. V2 packages don't get any of this complexity, they're\n // supposed to take care of colocating their own templates explicitly.\n packageGuard: true,\n };\n return [templateColocationPluginPath, colocationOptions];\n}\n\nexport function babelCompatSupport(): PluginItem[] {\n return [...babelMacros(), ...oldDebugMacros(), templateColocation(), ...pluginsFromV1Addons()];\n}\n\nexport function templateCompatSupport(): Transform[] {\n return [...transformsFromV1Addons(), ...templateMacros(), looseModeSupport()];\n}\n"]}
1
+ {"version":3,"file":"babel.js","sourceRoot":"","sources":["babel.ts"],"names":[],"mappings":";;AAuCA,kDAGC;AAED,wDAGC;AAED,4CAOC;AAED,wCAGC;AAED,kCAGC;AAED,wCAyCC;AAED,gDAkCC;AAED,gDAEC;AAED,sDAEC;AAxJD,2BAAgC;AAChC,0CAKyB;AACzB,+BAA4B;AAG5B,mDAAsD;AAStD,SAAS,gBAAgB;IACvB,IAAI,UAAU,GAAG,IAAA,WAAI,EAAC,IAAA,gCAAyB,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,mBAAmB,CAAC,CAAC;IACrF,IAAI,IAAA,eAAU,EAAC,UAAU,CAAC,EAAE,CAAC;QAC3B,iEAAiE;QACjE,OAAO,OAAO,CAAC,UAAU,CAAC,CAAC;IAC7B,CAAC;IAED,IAAI,MAAM,GAAG,IAAA,mBAAW,GAAE,CAAC;IAE3B,OAAO;QACL,OAAO,EAAE,EAAE;QACX,kBAAkB,EAAE,EAAE;QACtB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,cAAc,EAAE,MAAM,CAAC,cAAqB;KAC7C,CAAC;AACJ,CAAC;AAED,MAAM,cAAc,GAAG,IAAI,qBAAc,CAAC,OAAO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AW;YACX;gBACE,kBAAkB,EAAE;oBAClB,MAAM,EAAE,iCAAiC;iBAC1C;gBACD,UAAU,EAAE;oBACV,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE,iCAAiC;oBACzC,oBAAoB,EAAE,CAAC;iBACxB;aACF;YACD,2CAA2C;SAC5C;KACF,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB;IAChC,IAAI,iBAAiB,GAAoC;QACvD,OAAO,EAAE,cAAc,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO;QAEhD,sEAAsE;QACtE,EAAE;QACF,uEAAuE;QACvE,8CAA8C;QAC9C,EAAE;QACF,0EAA0E;QAC1E,wEAAwE;QACxE,qEAAqE;QACrE,2DAA2D;QAC3D,EAAE;QACF,uEAAuE;QACvE,4CAA4C;QAC5C,EAAE;QACF,+DAA+D;QAC/D,6DAA6D;QAC7D,wEAAwE;QACxE,sEAAsE;QACtE,gBAAgB;QAChB,EAAE;QACF,yEAAyE;QACzE,wEAAwE;QACxE,kBAAkB;QAClB,kBAAkB,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;QAEvC,oEAAoE;QACpE,wEAAwE;QACxE,sEAAsE;QACtE,YAAY,EAAE,IAAI;KACnB,CAAC;IACF,OAAO,CAAC,mCAA4B,EAAE,iBAAiB,CAAC,CAAC;AAC3D,CAAC;AAED,SAAgB,kBAAkB;IAChC,OAAO,CAAC,GAAG,WAAW,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,kBAAkB,EAAE,EAAE,GAAG,mBAAmB,EAAE,CAAC,CAAC;AACjG,CAAC;AAED,SAAgB,qBAAqB;IACnC,OAAO,CAAC,GAAG,sBAAsB,EAAE,EAAE,GAAG,cAAc,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;AAChF,CAAC","sourcesContent":["import type { PluginItem } from '@babel/core';\nimport { existsSync } from 'fs';\nimport {\n locateEmbroiderWorkingDir,\n ResolverLoader,\n templateColocationPluginPath,\n type TemplateColocationPluginOptions,\n} from '@embroider/core';\nimport { join } from 'path';\nimport type { Transform } from 'babel-plugin-ember-template-compilation';\nimport type { Options as ResolverTransformOptions } from './resolver-transform';\nimport { buildMacros } from '@embroider/macros/babel';\n\nexport interface CompatBabelState {\n plugins: PluginItem[];\n templateTransforms: Transform[];\n babelMacros: PluginItem[];\n templateMacros: Transform[];\n}\n\nfunction loadCompatConfig(): CompatBabelState {\n let compatFile = join(locateEmbroiderWorkingDir(process.cwd()), '_babel_compat_.js');\n if (existsSync(compatFile)) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(compatFile);\n }\n\n let macros = buildMacros();\n\n return {\n plugins: [],\n templateTransforms: [],\n babelMacros: macros.babelMacros,\n templateMacros: macros.templateMacros as any,\n };\n}\n\nconst resolverLoader = new ResolverLoader(process.cwd());\n\nexport function pluginsFromV1Addons() {\n let config = loadCompatConfig();\n return config.plugins;\n}\n\nexport function transformsFromV1Addons() {\n let config = loadCompatConfig();\n return config.templateTransforms;\n}\n\nexport function looseModeSupport(): Transform {\n const { resolver } = resolverLoader;\n let opts: ResolverTransformOptions = {\n appRoot: resolver.options.appRoot,\n emberVersion: resolver.options.emberVersion,\n };\n return [require.resolve('./resolver-transform'), opts];\n}\n\nexport function templateMacros() {\n let config = loadCompatConfig();\n return config.templateMacros;\n}\n\nexport function babelMacros() {\n let config = loadCompatConfig();\n return config.babelMacros;\n}\n\nexport function oldDebugMacros(): PluginItem[] {\n let debugMacros = require.resolve('babel-plugin-debug-macros');\n return [\n [\n debugMacros,\n {\n flags: [\n {\n source: '@glimmer/env',\n flags: {\n DEBUG: true,\n CI: false,\n },\n },\n ],\n debugTools: {\n isDebug: true,\n source: '@ember/debug',\n assertPredicateIndex: 1,\n },\n externalizeHelpers: {\n module: '@ember/debug',\n },\n },\n '@ember/debug stripping',\n ],\n [\n debugMacros,\n {\n externalizeHelpers: {\n module: '@ember/application/deprecations',\n },\n debugTools: {\n isDebug: true,\n source: '@ember/application/deprecations',\n assertPredicateIndex: 1,\n },\n },\n '@ember/application/deprecations stripping',\n ],\n ];\n}\n\nexport function templateColocation(): PluginItem {\n let colocationOptions: TemplateColocationPluginOptions = {\n appRoot: resolverLoader.resolver.options.appRoot,\n\n // This extra weirdness is a compromise in favor of build performance.\n //\n // 1. When auto-upgrading an addon from v1 to v2, we definitely want to\n // run any custom AST transforms in stage1.\n //\n // 2. In general case, AST transforms are allowed to manipulate Javascript\n // scope. This means that running transforms -- even when we're doing\n // source-to-source compilation that emits handlebars and not wire\n // format -- implies changing .hbs files into .js files.\n //\n // 3. So stage1 may need to rewrite .hbs to .hbs.js (to avoid colliding\n // with an existing co-located .js file).\n //\n // 4. But stage1 doesn't necessarily want to run babel over the\n // corresponding JS file. Most of the time, that's just an\n // unnecessarily expensive second parse. (We only run it in stage1 to\n // eliminate an addon's custom babel plugins, and many addons don't\n // have any.)\n //\n // 5. Therefore, the work of template-colocation gets defered until here,\n // and it may see co-located templates named `.hbs.js` instead of the\n // usual `.hbs.\n templateExtensions: ['.hbs', '.hbs.js'],\n\n // All of the above only applies to auto-upgraded packages that were\n // authored in v1. V2 packages don't get any of this complexity, they're\n // supposed to take care of colocating their own templates explicitly.\n packageGuard: true,\n };\n return [templateColocationPluginPath, colocationOptions];\n}\n\nexport function babelCompatSupport(): PluginItem[] {\n return [...babelMacros(), ...oldDebugMacros(), templateColocation(), ...pluginsFromV1Addons()];\n}\n\nexport function templateCompatSupport(): Transform[] {\n return [...transformsFromV1Addons(), ...templateMacros(), looseModeSupport()];\n}\n"]}
@@ -103,6 +103,9 @@ class default_1 extends v1_addon_1.default {
103
103
  // error.
104
104
  trees.push(new FixStringLoc([packages]));
105
105
  }
106
+ if ((0, semver_1.satisfies)(this.packageJSON.version, '<5.12.0')) {
107
+ trees.push(new FixDeprecateFunction([packages]));
108
+ }
106
109
  return (0, broccoli_merge_trees_1.default)(trees, { overwrite: true });
107
110
  }
108
111
  // We're zeroing out these files in vendor rather than deleting them, because
@@ -153,6 +156,61 @@ class FixStringLoc extends broccoli_plugin_1.default {
153
156
  (0, fs_extra_1.outputFileSync)((0, path_1.resolve)(this.outputPath, 'ember', 'index.js'), outSource, 'utf8');
154
157
  }
155
158
  }
159
+ class FixDeprecateFunction extends broccoli_plugin_1.default {
160
+ build() {
161
+ let inSource = (0, fs_extra_1.readFileSync)((0, path_1.resolve)(this.inputPaths[0], '@ember', 'debug', 'index.js'), 'utf8');
162
+ let outSource = (0, core_1.transform)(inSource, {
163
+ plugins: [fixDeprecate],
164
+ configFile: false,
165
+ }).code;
166
+ (0, fs_extra_1.outputFileSync)((0, path_1.resolve)(this.outputPath, '@ember', 'debug', 'index.js'), outSource, 'utf8');
167
+ }
168
+ }
169
+ function fixDeprecate(babel) {
170
+ const { types: t } = babel;
171
+ return {
172
+ name: 'ast-transform', // not required
173
+ visitor: {
174
+ Program(path) {
175
+ path.node.body.unshift(t.functionDeclaration(t.identifier('newDeprecate'), [t.restElement(t.identifier('rest'))], t.blockStatement([
176
+ t.returnStatement(t.callExpression(t.logicalExpression('??', t.identifier('currentDeprecate'), t.identifier('_deprecate')), [t.spreadElement(t.identifier('rest'))])),
177
+ ])));
178
+ },
179
+ AssignmentExpression(path) {
180
+ if (path.node.left.type === 'Identifier' && path.node.left.name === 'deprecate') {
181
+ path.node.left.name = 'currentDeprecate';
182
+ }
183
+ },
184
+ ReturnStatement(path) {
185
+ var _a;
186
+ if (((_a = path.node.argument) === null || _a === void 0 ? void 0 : _a.type) === 'Identifier' && path.node.argument.name === 'deprecate') {
187
+ path.node.argument.name = 'newDeprecate';
188
+ }
189
+ },
190
+ CallExpression(path) {
191
+ if (path.node.callee.type === 'Identifier' && path.node.callee.name === 'deprecate') {
192
+ path.node.callee.name = 'newDeprecate';
193
+ }
194
+ if (path.node.callee.type === 'Identifier' &&
195
+ path.node.callee.name === 'setDebugFunction' &&
196
+ path.node.arguments[0].type === 'StringLiteral' &&
197
+ path.node.arguments[0].value === 'deprecate') {
198
+ path.remove();
199
+ }
200
+ },
201
+ ExportSpecifier(path) {
202
+ if (path.node.local.name === 'deprecate') {
203
+ path.node.local = t.identifier('newDeprecate');
204
+ }
205
+ },
206
+ VariableDeclarator(path) {
207
+ if (path.node.id.type === 'Identifier' && path.node.id.name === 'deprecate') {
208
+ path.node.id.name = 'currentDeprecate';
209
+ }
210
+ },
211
+ },
212
+ };
213
+ }
156
214
  function fixStringLoc(babel) {
157
215
  let t = babel.types;
158
216
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"ember-source.js","sourceRoot":"","sources":["ember-source.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkC;AAClC,sEAA0C;AAC1C,gFAA8C;AAC9C,iEAAuC;AACvC,uCAAiF;AACjF,+BAAqC;AACrC,2DAA6C;AAC7C,mCAAmC;AACnC,sCAAwC;AAGxC,sEAAqC;AAErC,2BAAgC;AAEhC,eAAqB,SAAQ,kBAAO;IAClC,IAAI,MAAM;QACR,OAAO,IAAA,8BAAU,EAAC,CAAC,KAAK,CAAC,MAAM,EAAE,IAAA,yBAAW,EAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,iCAAiC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClH,CAAC;IAED,oCAAoC;IACpC,wEAAwE;IACxE,6EAA6E;IAC7E,qEAAqE;IACrE,2EAA2E;IAC3E,yEAAyE;IACzE,6BAA6B;IAC7B,EAAE;IACF,2EAA2E;IAC3E,oEAAoE;IACpE,uEAAuE;IACvE,4EAA4E;IAC5E,2CAA2C;IAE3C,IAAY,oBAAoB;QAC9B,IAAI,MAAM,GAAa,EAAE,CAAC;QAC1B,IAAI,OAAO,GAAG,IAAA,cAAO,EAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,cAAc,CAAC,CAAC;QACzD,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,EAAE,CAAC;YACzB,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,KAAK,IAAI,IAAI,IAAI,IAAA,sBAAW,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IAAI,KAAK,KAAK,EAAE,CAAC;oBAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import V1Addon from '../v1-addon';\nimport buildFunnel from 'broccoli-funnel';\nimport mergeTrees from 'broccoli-merge-trees';\nimport AddToTree from '../add-to-tree';\nimport { outputFileSync, readFileSync, readdirSync, unlinkSync } from 'fs-extra';\nimport { join, resolve } from 'path';\nimport { Memoize } from 'typescript-memoize';\nimport { satisfies } from 'semver';\nimport { transform } from '@babel/core';\nimport type * as Babel from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport Plugin from 'broccoli-plugin';\nimport type { Node } from 'broccoli-node-api';\nimport { existsSync } from 'fs';\n\nexport default class extends V1Addon {\n get v2Tree() {\n return mergeTrees([super.v2Tree, buildFunnel(this.rootTree, { include: ['dist/ember-template-compiler.js'] })]);\n }\n\n // versions of ember-source prior to\n // https://github.com/emberjs/ember.js/pull/20675 ship dist/packages and\n // dist/dependencies separately and the imports between them are package-name\n // imports. Since many of the dependencies are also true package.json\n // dependencies (in order to get typescript types), and our module-resolver\n // prioritizes true dependencies, it's necessary to detect and remove the\n // package.json dependencies.\n //\n // After the above linked change, ember-source ships only dist/packages and\n // the inter-package imports are all relative. Some of the things in\n // dist/packages are still the rolled-in dependencies, but now that the\n // imports are all relative we need no special handling for them (beyond the\n // normal v2 addon renamed-modules support.\n @Memoize()\n private get includedDependencies() {\n let result: string[] = [];\n let depsDir = resolve(this.root, 'dist', 'dependencies');\n if (!existsSync(depsDir)) {\n return result;\n }\n for (let name of readdirSync(depsDir)) {\n if (name[0] === '@') {\n for (let innerName of readdirSync(resolve(this.root, 'dist', 'dependencies', name))) {\n if (innerName.endsWith('.js')) {\n result.push(name + '/' + innerName.slice(0, -3));\n }\n }\n } else {\n if (name.endsWith('.js')) {\n result.push(name.slice(0, -3));\n }\n }\n }\n return result;\n }\n\n get newPackageJSON() {\n let json = super.newPackageJSON;\n\n for (let name of this.includedDependencies) {\n // weirdly, many of the inlined dependency are still listed as real\n // dependencies too. If we don't delete them here, they will take\n // precedence over the inlined ones, because the embroider module-resolver\n // tries to prioritize real deps.\n delete json.dependencies?.[name];\n }\n\n return json;\n }\n\n customizes(treeName: string) {\n // we are adding custom implementations of these\n return treeName === 'treeForAddon' || treeName === 'treeForVendor' || super.customizes(treeName);\n }\n\n invokeOriginalTreeFor(name: string) {\n if (name === 'addon') {\n return this.customAddonTree();\n }\n if (name === 'vendor') {\n return this.customVendorTree();\n }\n }\n\n // Our addon tree is all of the \"packages\" we share. @embroider/compat already\n // supports that pattern of emitting modules into other package's namespaces.\n private customAddonTree() {\n let packages = buildFunnel(this.rootTree, {\n srcDir: 'dist/packages',\n });\n\n let trees: Node[] = [\n packages,\n buildFunnel(this.rootTree, {\n srcDir: 'dist/dependencies',\n allowEmpty: true,\n }),\n ];\n\n if (satisfies(this.packageJSON.version, '>= 4.0.0-alpha.0 <4.10.0-alpha.0', { includePrerelease: true })) {\n // import { loc } from '@ember/string' was removed in 4.0. but the\n // top-level `ember` package tries to import it until 4.10. A\n // spec-compliant ES modules implementation will treat this as a parse\n // error.\n trees.push(new FixStringLoc([packages]));\n }\n\n return mergeTrees(trees, { overwrite: true });\n }\n\n // We're zeroing out these files in vendor rather than deleting them, because\n // we can't easily intercept the `app.import` that presumably exists for them,\n // so rather than error they will just be empty.\n //\n // The reason we're zeroing these out is that we're going to consume all our\n // modules directly out of treeForAddon instead, as real modules that webpack\n // can see.\n private customVendorTree() {\n return new AddToTree(this.addonInstance._treeFor('vendor'), outputPath => {\n unlinkSync(join(outputPath, 'ember', 'ember.js'));\n outputFileSync(join(outputPath, 'ember', 'ember.js'), '');\n unlinkSync(join(outputPath, 'ember', 'ember-testing.js'));\n outputFileSync(join(outputPath, 'ember', 'ember-testing.js'), '');\n });\n }\n\n get packageMeta() {\n let meta = super.packageMeta;\n\n if (!meta['implicit-modules']) {\n meta['implicit-modules'] = [];\n }\n meta['implicit-modules'].push('./ember/index.js');\n // before 5.6, Ember uses the AMD loader to decide if it's test-only parts\n // are present, so we must ensure they're registered. After that it's\n // enough to evaluate ember-testing, which @embroider/core is hard-coded\n // to do in the backward-compatible tests bundle.\n if (!satisfies(this.packageJSON.version, '>= 5.6.0-alpha.0', { includePrerelease: true })) {\n if (!meta['implicit-test-modules']) {\n meta['implicit-test-modules'] = [];\n }\n meta['implicit-test-modules'].push('./ember-testing/index.js');\n }\n\n return meta;\n }\n}\n\nclass FixStringLoc extends Plugin {\n build() {\n let inSource = readFileSync(resolve(this.inputPaths[0], 'ember', 'index.js'), 'utf8');\n let outSource = transform(inSource, {\n plugins: [fixStringLoc],\n configFile: false,\n })!.code!;\n outputFileSync(resolve(this.outputPath, 'ember', 'index.js'), outSource, 'utf8');\n }\n}\n\nfunction fixStringLoc(babel: typeof Babel) {\n let t = babel.types;\n return {\n visitor: {\n Program(path: NodePath<Babel.types.Program>) {\n path.node.body.unshift(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier('loc'), t.identifier('undefined'))])\n );\n },\n ImportDeclaration: {\n enter(path: NodePath<Babel.types.ImportDeclaration>, state: { inEmberString: boolean }) {\n if (path.node.source.value === '@ember/string') {\n state.inEmberString = true;\n }\n },\n exit(_path: NodePath<Babel.types.ImportDeclaration>, state: { inEmberString: boolean }) {\n state.inEmberString = false;\n },\n },\n ImportSpecifier(path: NodePath<Babel.types.ImportSpecifier>, state: { inEmberString: boolean }) {\n let name = 'value' in path.node.imported ? path.node.imported.value : path.node.imported.name;\n if (state.inEmberString && name === 'loc') {\n path.remove();\n }\n },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"ember-source.js","sourceRoot":"","sources":["ember-source.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkC;AAClC,sEAA0C;AAC1C,gFAA8C;AAC9C,iEAAuC;AACvC,uCAAiF;AACjF,+BAAqC;AACrC,2DAA6C;AAC7C,mCAAmC;AACnC,sCAAwC;AAGxC,sE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AC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAC9F,IAAI,KAAK,CAAC,aAAa,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;oBAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import V1Addon from '../v1-addon';\nimport buildFunnel from 'broccoli-funnel';\nimport mergeTrees from 'broccoli-merge-trees';\nimport AddToTree from '../add-to-tree';\nimport { outputFileSync, readFileSync, readdirSync, unlinkSync } from 'fs-extra';\nimport { join, resolve } from 'path';\nimport { Memoize } from 'typescript-memoize';\nimport { satisfies } from 'semver';\nimport { transform } from '@babel/core';\nimport type * as Babel from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport Plugin from 'broccoli-plugin';\nimport type { Node } from 'broccoli-node-api';\nimport { existsSync } from 'fs';\n\nexport default class extends V1Addon {\n get v2Tree() {\n return mergeTrees([super.v2Tree, buildFunnel(this.rootTree, { include: ['dist/ember-template-compiler.js'] })]);\n }\n\n // versions of ember-source prior to\n // https://github.com/emberjs/ember.js/pull/20675 ship dist/packages and\n // dist/dependencies separately and the imports between them are package-name\n // imports. Since many of the dependencies are also true package.json\n // dependencies (in order to get typescript types), and our module-resolver\n // prioritizes true dependencies, it's necessary to detect and remove the\n // package.json dependencies.\n //\n // After the above linked change, ember-source ships only dist/packages and\n // the inter-package imports are all relative. Some of the things in\n // dist/packages are still the rolled-in dependencies, but now that the\n // imports are all relative we need no special handling for them (beyond the\n // normal v2 addon renamed-modules support.\n @Memoize()\n private get includedDependencies() {\n let result: string[] = [];\n let depsDir = resolve(this.root, 'dist', 'dependencies');\n if (!existsSync(depsDir)) {\n return result;\n }\n for (let name of readdirSync(depsDir)) {\n if (name[0] === '@') {\n for (let innerName of readdirSync(resolve(this.root, 'dist', 'dependencies', name))) {\n if (innerName.endsWith('.js')) {\n result.push(name + '/' + innerName.slice(0, -3));\n }\n }\n } else {\n if (name.endsWith('.js')) {\n result.push(name.slice(0, -3));\n }\n }\n }\n return result;\n }\n\n get newPackageJSON() {\n let json = super.newPackageJSON;\n\n for (let name of this.includedDependencies) {\n // weirdly, many of the inlined dependency are still listed as real\n // dependencies too. If we don't delete them here, they will take\n // precedence over the inlined ones, because the embroider module-resolver\n // tries to prioritize real deps.\n delete json.dependencies?.[name];\n }\n\n return json;\n }\n\n customizes(treeName: string) {\n // we are adding custom implementations of these\n return treeName === 'treeForAddon' || treeName === 'treeForVendor' || super.customizes(treeName);\n }\n\n invokeOriginalTreeFor(name: string) {\n if (name === 'addon') {\n return this.customAddonTree();\n }\n if (name === 'vendor') {\n return this.customVendorTree();\n }\n }\n\n // Our addon tree is all of the \"packages\" we share. @embroider/compat already\n // supports that pattern of emitting modules into other package's namespaces.\n private customAddonTree() {\n let packages = buildFunnel(this.rootTree, {\n srcDir: 'dist/packages',\n });\n\n let trees: Node[] = [\n packages,\n buildFunnel(this.rootTree, {\n srcDir: 'dist/dependencies',\n allowEmpty: true,\n }),\n ];\n\n if (satisfies(this.packageJSON.version, '>= 4.0.0-alpha.0 <4.10.0-alpha.0', { includePrerelease: true })) {\n // import { loc } from '@ember/string' was removed in 4.0. but the\n // top-level `ember` package tries to import it until 4.10. A\n // spec-compliant ES modules implementation will treat this as a parse\n // error.\n trees.push(new FixStringLoc([packages]));\n }\n\n if (satisfies(this.packageJSON.version, '<5.12.0')) {\n trees.push(new FixDeprecateFunction([packages]));\n }\n\n return mergeTrees(trees, { overwrite: true });\n }\n\n // We're zeroing out these files in vendor rather than deleting them, because\n // we can't easily intercept the `app.import` that presumably exists for them,\n // so rather than error they will just be empty.\n //\n // The reason we're zeroing these out is that we're going to consume all our\n // modules directly out of treeForAddon instead, as real modules that webpack\n // can see.\n private customVendorTree() {\n return new AddToTree(this.addonInstance._treeFor('vendor'), outputPath => {\n unlinkSync(join(outputPath, 'ember', 'ember.js'));\n outputFileSync(join(outputPath, 'ember', 'ember.js'), '');\n unlinkSync(join(outputPath, 'ember', 'ember-testing.js'));\n outputFileSync(join(outputPath, 'ember', 'ember-testing.js'), '');\n });\n }\n\n get packageMeta() {\n let meta = super.packageMeta;\n\n if (!meta['implicit-modules']) {\n meta['implicit-modules'] = [];\n }\n meta['implicit-modules'].push('./ember/index.js');\n // before 5.6, Ember uses the AMD loader to decide if it's test-only parts\n // are present, so we must ensure they're registered. After that it's\n // enough to evaluate ember-testing, which @embroider/core is hard-coded\n // to do in the backward-compatible tests bundle.\n if (!satisfies(this.packageJSON.version, '>= 5.6.0-alpha.0', { includePrerelease: true })) {\n if (!meta['implicit-test-modules']) {\n meta['implicit-test-modules'] = [];\n }\n meta['implicit-test-modules'].push('./ember-testing/index.js');\n }\n\n return meta;\n }\n}\n\nclass FixStringLoc extends Plugin {\n build() {\n let inSource = readFileSync(resolve(this.inputPaths[0], 'ember', 'index.js'), 'utf8');\n let outSource = transform(inSource, {\n plugins: [fixStringLoc],\n configFile: false,\n })!.code!;\n outputFileSync(resolve(this.outputPath, 'ember', 'index.js'), outSource, 'utf8');\n }\n}\n\nclass FixDeprecateFunction extends Plugin {\n build() {\n let inSource = readFileSync(resolve(this.inputPaths[0], '@ember', 'debug', 'index.js'), 'utf8');\n let outSource = transform(inSource, {\n plugins: [fixDeprecate],\n configFile: false,\n })!.code!;\n outputFileSync(resolve(this.outputPath, '@ember', 'debug', 'index.js'), outSource, 'utf8');\n }\n}\n\nfunction fixDeprecate(babel: typeof Babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n Program(path: NodePath<Babel.types.Program>) {\n path.node.body.unshift(\n t.functionDeclaration(\n t.identifier('newDeprecate'),\n [t.restElement(t.identifier('rest'))],\n t.blockStatement([\n t.returnStatement(\n t.callExpression(\n t.logicalExpression('??', t.identifier('currentDeprecate'), t.identifier('_deprecate')),\n [t.spreadElement(t.identifier('rest'))]\n )\n ),\n ])\n )\n );\n },\n AssignmentExpression(path: NodePath<Babel.types.AssignmentExpression>) {\n if (path.node.left.type === 'Identifier' && path.node.left.name === 'deprecate') {\n path.node.left.name = 'currentDeprecate';\n }\n },\n\n ReturnStatement(path: NodePath<Babel.types.ReturnStatement>) {\n if (path.node.argument?.type === 'Identifier' && path.node.argument.name === 'deprecate') {\n path.node.argument.name = 'newDeprecate';\n }\n },\n\n CallExpression(path: NodePath<Babel.types.CallExpression>) {\n if (path.node.callee.type === 'Identifier' && path.node.callee.name === 'deprecate') {\n path.node.callee.name = 'newDeprecate';\n }\n if (\n path.node.callee.type === 'Identifier' &&\n path.node.callee.name === 'setDebugFunction' &&\n path.node.arguments[0].type === 'StringLiteral' &&\n path.node.arguments[0].value === 'deprecate'\n ) {\n path.remove();\n }\n },\n ExportSpecifier(path: NodePath<Babel.types.ExportSpecifier>) {\n if (path.node.local.name === 'deprecate') {\n path.node.local = t.identifier('newDeprecate');\n }\n },\n VariableDeclarator(path: NodePath<Babel.types.VariableDeclarator>) {\n if (path.node.id.type === 'Identifier' && path.node.id.name === 'deprecate') {\n path.node.id.name = 'currentDeprecate';\n }\n },\n },\n };\n}\n\nfunction fixStringLoc(babel: typeof Babel) {\n let t = babel.types;\n return {\n visitor: {\n Program(path: NodePath<Babel.types.Program>) {\n path.node.body.unshift(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier('loc'), t.identifier('undefined'))])\n );\n },\n ImportDeclaration: {\n enter(path: NodePath<Babel.types.ImportDeclaration>, state: { inEmberString: boolean }) {\n if (path.node.source.value === '@ember/string') {\n state.inEmberString = true;\n }\n },\n exit(_path: NodePath<Babel.types.ImportDeclaration>, state: { inEmberString: boolean }) {\n state.inEmberString = false;\n },\n },\n ImportSpecifier(path: NodePath<Babel.types.ImportSpecifier>, state: { inEmberString: boolean }) {\n let name = 'value' in path.node.imported ? path.node.imported.value : path.node.imported.name;\n if (state.inEmberString && name === 'loc') {\n path.remove();\n }\n },\n },\n };\n}\n"]}