@embroider/core 0.46.2 → 0.48.0

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 (46) hide show
  1. package/package.json +4 -4
  2. package/src/app-files.d.ts +1 -0
  3. package/src/app-files.js +11 -3
  4. package/src/app-files.js.map +1 -1
  5. package/src/app.js +30 -8
  6. package/src/app.js.map +1 -1
  7. package/src/babel-plugin-adjust-imports.d.ts +6 -5
  8. package/src/babel-plugin-adjust-imports.js.map +1 -1
  9. package/src/babel-plugin-inline-hbs-deps-node.d.ts +14 -0
  10. package/src/babel-plugin-inline-hbs-deps-node.js +27 -0
  11. package/src/babel-plugin-inline-hbs-deps-node.js.map +1 -0
  12. package/src/babel-plugin-inline-hbs-deps.d.ts +10 -0
  13. package/src/babel-plugin-inline-hbs-deps.js +119 -0
  14. package/src/babel-plugin-inline-hbs-deps.js.map +1 -0
  15. package/src/babel-plugin-inline-hbs-node.d.ts +3 -9
  16. package/src/babel-plugin-inline-hbs-node.js.map +1 -1
  17. package/src/babel-plugin-inline-hbs.d.ts +5 -7
  18. package/src/babel-plugin-inline-hbs.js +35 -73
  19. package/src/babel-plugin-inline-hbs.js.map +1 -1
  20. package/src/babel-plugin-stage1-inline-hbs-node.d.ts +12 -0
  21. package/src/babel-plugin-stage1-inline-hbs-node.js +9 -0
  22. package/src/babel-plugin-stage1-inline-hbs-node.js.map +1 -0
  23. package/src/babel-plugin-stage1-inline-hbs.d.ts +9 -0
  24. package/src/babel-plugin-stage1-inline-hbs.js +96 -0
  25. package/src/babel-plugin-stage1-inline-hbs.js.map +1 -0
  26. package/src/describe-exports.js +3 -3
  27. package/src/describe-exports.js.map +1 -1
  28. package/src/mini-modules-polyfill.d.ts +1 -1
  29. package/src/mini-modules-polyfill.js.map +1 -1
  30. package/src/options.d.ts +1 -0
  31. package/src/options.js +1 -0
  32. package/src/options.js.map +1 -1
  33. package/src/patch-template-compiler.js +3 -4
  34. package/src/patch-template-compiler.js.map +1 -1
  35. package/src/rename-require-plugin.js.map +1 -1
  36. package/src/template-compiler-common.d.ts +3 -1
  37. package/src/template-compiler-common.js +8 -12
  38. package/src/template-compiler-common.js.map +1 -1
  39. package/src/template-compiler-node.js +3 -3
  40. package/src/template-compiler-node.js.map +1 -1
  41. package/src/babel-import-adder.d.ts +0 -11
  42. package/src/babel-import-adder.js +0 -75
  43. package/src/babel-import-adder.js.map +0 -1
  44. package/src/template-colocation-plugin.d.ts +0 -22
  45. package/src/template-colocation-plugin.js +0 -113
  46. package/src/template-colocation-plugin.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"babel-plugin-inline-hbs.js","sourceRoot":"","sources":["babel-plugin-inline-hbs.ts"],"names":[],"mappings":";;AAEA,+BAA4B;AAE5B,sCAAoC;AAEpC,yDAA+C;AAI/C,4EAA4E;AAC5E,6EAA6E;AAC7E,2BAA2B;AAC3B,MAAM,WAAW,GAAG;IAClB,CAAC,4BAA4B,EAAE,SAAS,CAAC;IACzC,CAAC,sCAAsC,EAAE,SAAS,CAAC;IACnD,CAAC,oBAAoB,EAAE,KAAK,CAAC;CAC9B,CAAC;AAwBF,SAAwB,IAAI,CAAC,WAA4C;IACvE,SAAS,kBAAkB,CAAC,KAAc;QACxC,IAAI,CAAC,GAAI,KAAa,CAAC,KAAmB,CAAC;QAC3C,OAAO;YACL,OAAO,EAAE;gBACP,OAAO,EAAE;oBACP,KAAK,CAAC,IAAyB,EAAE,KAAY;wBAC3C,KAAK,CAAC,YAAY,GAAG,IAAI,GAAG,EAAE,CAAC;wBAC/B,KAAK,CAAC,KAAK,GAAG,IAAI,8BAAU,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;oBACxC,CAAC;oBACD,IAAI,CAAC,IAAyB,EAAE,KAAY;wBAC1C,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,EAAE;4BAC1B,YAAY,CAAC,IAAI,CAAC,CAAC;yBACpB;wBACD,IAAI,OAAO,GAAG,CAAC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AQ,CAAE,IAAI,MAAK,iBAAiB,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE;YACxE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;SACxC;QACD,MAAM,IAAI,CAAC,mBAAmB,CAAC,4CAA4C,CAAC,CAAC;IAC/E,CAAC;IAED,SAAS,gBAAgB,CAAC,IAAgC;QACxD,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QAE9C,IAAI,mBAAmB,GACrB,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,MAAK,kBAAkB;YACpC,OAAO,CAAC,UAAU,CAAC,IAAI,CACrB,IAAI,CAAC,EAAE,CACL,IAAI,CAAC,IAAI,KAAK,gBAAgB;gBAC9B,IAAI,CAAC,QAAQ,KAAK,KAAK;gBACvB,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;gBAC9B,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,qBAAqB;gBACvC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,gBAAgB;gBACpC,IAAI,CAAC,KAAK,CAAC,KAAK,CACnB,CAAC;QAEJ,OAAO;YACL,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAAC;YAC3C,mBAAmB;SACpB,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AAvMD,uBAuMC","sourcesContent":["import type * as t from '@babel/types';\nimport type { NodePath } from '@babel/traverse';\nimport { join } from 'path';\nimport { TemplateCompiler } from './template-compiler-common';\nimport { parse } from '@babel/core';\nimport { ResolvedDep } from './resolver';\nimport { ImportUtil } from 'babel-import-util';\n\ntype BabelTypes = typeof t;\n\n// These are the known names that people are using to import the `hbs` macro\n// from. In theory the original plugin lets people customize these names, but\n// that is a terrible idea.\nconst modulePaths = [\n ['htmlbars-inline-precompile', 'default'],\n ['ember-cli-htmlbars-inline-precompile', 'default'],\n ['ember-cli-htmlbars', 'hbs'],\n];\n\ninterface State {\n opts: {\n // the stages here correspond to the two places in the overall Embroider\n // architecture that this transform applies. In stage1 HBS stays as HBS, but\n // we still need to run any custom AST transforms inside that HBS. In\n // stage3, we are running more like the traditional\n // ember-cli-htmlbars-inline-precompile by compiling the HBS to Javascript.\n stage: 1 | 3;\n };\n file: {\n code: string;\n opts: {\n filename: string;\n };\n };\n dependencies: Map<string, ResolvedDep>;\n templateCompiler: TemplateCompiler | undefined;\n adder: ImportUtil;\n}\n\nexport type Params = State['opts'];\n\nexport default function make(getCompiler: (opts: any) => TemplateCompiler) {\n function inlineHBSTransform(babel: unknown): unknown {\n let t = (babel as any).types as BabelTypes;\n return {\n visitor: {\n Program: {\n enter(path: NodePath<t.Program>, state: State) {\n state.dependencies = new Map();\n state.adder = new ImportUtil(t, path);\n },\n exit(path: NodePath<t.Program>, state: State) {\n if (state.opts.stage === 3) {\n pruneImports(path);\n }\n let counter = 0;\n for (let dep of state.dependencies.values()) {\n path.node.body.unshift(amdDefine(dep.runtimeName, counter, t));\n path.node.body.unshift(\n t.importDeclaration(\n [t.importDefaultSpecifier(t.identifier(`a${counter++}`))],\n t.stringLiteral(dep.path)\n )\n );\n }\n },\n },\n TaggedTemplateExpression(path: NodePath<t.TaggedTemplateExpression>, state: State) {\n for (let [modulePath, identifier] of modulePaths) {\n if (path.get('tag').referencesImport(modulePath, identifier)) {\n handleTagged(path, state, t);\n }\n }\n },\n CallExpression(path: NodePath<t.CallExpression>, state: State) {\n for (let [modulePath, identifier] of modulePaths) {\n if (path.get('callee').referencesImport(modulePath, identifier)) {\n handleCalled(path, state, t);\n }\n }\n },\n },\n };\n }\n\n inlineHBSTransform._parallelBabel = {\n requireFile: __filename,\n };\n\n inlineHBSTransform.baseDir = function () {\n return join(__dirname, '..');\n };\n\n function handleTagged(path: NodePath<t.TaggedTemplateExpression>, state: State, t: BabelTypes) {\n if (path.node.quasi.expressions.length) {\n throw path.buildCodeFrameError('placeholders inside a tagged template string are not supported');\n }\n let template = path.node.quasi.quasis.map(quasi => quasi.value.cooked).join('');\n if (state.opts.stage === 1) {\n let compiled = compiler(state).applyTransforms(state.file.opts.filename, template);\n path.get('quasi').replaceWith(t.templateLiteral([t.templateElement({ raw: compiled, cooked: compiled })], []));\n } else {\n let { compiled, dependencies } = compiler(state).precompile(state.file.opts.filename, template);\n for (let dep of dependencies) {\n state.dependencies.set(dep.runtimeName, dep);\n }\n\n path.replaceWith(\n t.callExpression(state.adder.import(path, '@ember/template-factory', 'createTemplateFactory'), [\n jsonLiteral(compiled, t),\n ])\n );\n }\n }\n\n function handleCalled(path: NodePath<t.CallExpression>, state: State, t: BabelTypes) {\n let { template, insertRuntimeErrors } = getCallArguments(path);\n let compilerInstance = compiler(state);\n\n if (state.opts.stage === 1) {\n let compiled: string;\n try {\n compiled = compilerInstance.applyTransforms(state.file.opts.filename, template);\n } catch (err) {\n if (insertRuntimeErrors) {\n // in stage 1 we just leave the bad template in place (we were only\n // trying to run transforms and re-emit hbs), so that it will be handled\n // at stage3 instead.\n return;\n }\n throw err;\n }\n (path.get('arguments')[0] as NodePath).replaceWith(t.stringLiteral(compiled));\n } else {\n let result: ReturnType<TemplateCompiler['precompile']>;\n try {\n result = compilerInstance.precompile(state.file.opts.filename, template);\n } catch (err) {\n if (insertRuntimeErrors) {\n path.replaceWith(\n t.callExpression(\n t.functionExpression(\n null,\n [],\n t.blockStatement([\n t.throwStatement(t.newExpression(t.identifier('Error'), [t.stringLiteral(err.message)])),\n ])\n ),\n []\n )\n );\n return;\n }\n throw err;\n }\n let { compiled, dependencies } = result;\n for (let dep of dependencies) {\n state.dependencies.set(dep.runtimeName, dep);\n }\n path.replaceWith(\n t.callExpression(state.adder.import(path, '@ember/template-factory', 'createTemplateFactory'), [\n jsonLiteral(compiled, t),\n ])\n );\n }\n }\n\n function pruneImports(path: NodePath) {\n if (!path.isProgram()) {\n return;\n }\n for (let topLevelPath of path.get('body')) {\n if (topLevelPath.isImportDeclaration()) {\n let modulePath = topLevelPath.get('source').node.value;\n if (modulePaths.find(p => p[0] === modulePath)) {\n topLevelPath.remove();\n }\n }\n }\n }\n\n function jsonLiteral(value: unknown | undefined, t: BabelTypes) {\n if (typeof value === 'undefined') {\n return t.identifier('undefined');\n }\n let ast = parse(`a(${value})`, {}) as t.File;\n let statement = ast.program.body[0] as t.ExpressionStatement;\n let expression = statement.expression as t.CallExpression;\n return expression.arguments[0];\n }\n\n function compiler(state: State) {\n if (!state.templateCompiler) {\n state.templateCompiler = getCompiler(state.opts);\n }\n return state.templateCompiler;\n }\n\n function amdDefine(runtimeName: string, importCounter: number, t: BabelTypes) {\n return t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier('window'), t.identifier('define')), [\n t.stringLiteral(runtimeName),\n t.functionExpression(null, [], t.blockStatement([t.returnStatement(t.identifier(`a${importCounter}`))])),\n ])\n );\n }\n\n function getTemplateString(template: any, path: NodePath<t.CallExpression>): string {\n if (template?.type === 'StringLiteral') {\n return template.value;\n }\n // treat inert TemplateLiteral (without subexpressions) like a StringLiteral\n if (template?.type === 'TemplateLiteral' && !template.expressions.length) {\n return template.quasis[0].value.cooked;\n }\n throw path.buildCodeFrameError('hbs accepts only a string literal argument');\n }\n\n function getCallArguments(path: NodePath<t.CallExpression>): { template: string; insertRuntimeErrors: boolean } {\n let [template, options] = path.node.arguments;\n\n let insertRuntimeErrors =\n options?.type === 'ObjectExpression' &&\n options.properties.some(\n prop =>\n prop.type === 'ObjectProperty' &&\n prop.computed === false &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'insertRuntimeErrors' &&\n prop.value.type === 'BooleanLiteral' &&\n prop.value.value\n );\n\n return {\n template: getTemplateString(template, path),\n insertRuntimeErrors,\n };\n }\n\n return inlineHBSTransform;\n}\n"]}
1
+ {"version":3,"file":"babel-plugin-inline-hbs.js","sourceRoot":"","sources":["babel-plugin-inline-hbs.ts"],"names":[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ACvC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,gBAAgB;gBACpC,IAAI,CAAC,KAAK,CAAC,KAAK,CACnB,CAAC;QAEJ,OAAO;YACL,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAAC;YAC3C,mBAAmB;SACpB,CAAC;IACJ,CAAC;IAED,OAAO,kBAAkB,CAAC;AAC5B,CAAC;AApKD,uBAoKC","sourcesContent":["/*\n This plugin is used only for Ember < 3.27. For newer Ember's we have a\n different implementation that shares the standard\n babel-plugin-htmlbars-inline-precompile and supports passing Javascript\n lexically scoped names into templates.\n*/\n\nimport type { types as t } from '@babel/core';\nimport type * as Babel from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport { join } from 'path';\nimport { TemplateCompiler } from './template-compiler-common';\nimport { parse } from '@babel/core';\nimport { ResolvedDep } from './resolver';\nimport { ImportUtil } from 'babel-import-util';\nimport { templateCompilationModules } from '@embroider/shared-internals';\n\ntype BabelTypes = typeof t;\n\ninterface State<O> {\n opts: O;\n file: {\n code: string;\n opts: {\n filename: string;\n };\n };\n dependencies: Map<string, ResolvedDep>;\n templateCompiler: TemplateCompiler | undefined;\n adder: ImportUtil;\n}\n\nexport default function make<O>(getCompiler: (opts: O) => TemplateCompiler) {\n function inlineHBSTransform(babel: typeof Babel): Babel.PluginObj<State<O>> {\n let t = babel.types;\n return {\n visitor: {\n Program: {\n enter(path: NodePath<t.Program>, state: State<O>) {\n state.dependencies = new Map();\n state.adder = new ImportUtil(t, path);\n },\n exit(path: NodePath<t.Program>, state: State<O>) {\n for (let { module, exportedName } of templateCompilationModules) {\n state.adder.removeImport(module, exportedName);\n }\n let counter = 0;\n for (let dep of state.dependencies.values()) {\n path.node.body.unshift(amdDefine(dep.runtimeName, counter, t));\n path.node.body.unshift(\n t.importDeclaration(\n [t.importDefaultSpecifier(t.identifier(`a${counter++}`))],\n t.stringLiteral(dep.path)\n )\n );\n }\n },\n },\n TaggedTemplateExpression(path: NodePath<t.TaggedTemplateExpression>, state: State<O>) {\n for (let { module, exportedName } of templateCompilationModules) {\n if (path.get('tag').referencesImport(module, exportedName)) {\n handleTagged(path, state, t);\n }\n }\n },\n CallExpression(path: NodePath<t.CallExpression>, state: State<O>) {\n for (let { module, exportedName } of templateCompilationModules) {\n if (path.get('callee').referencesImport(module, exportedName)) {\n handleCalled(path, state, t);\n }\n }\n },\n },\n };\n }\n\n inlineHBSTransform._parallelBabel = {\n requireFile: __filename,\n };\n\n inlineHBSTransform.baseDir = function () {\n return join(__dirname, '..');\n };\n\n function handleTagged(path: NodePath<t.TaggedTemplateExpression>, state: State<O>, t: BabelTypes) {\n if (path.node.quasi.expressions.length) {\n throw path.buildCodeFrameError('placeholders inside a tagged template string are not supported');\n }\n let template = path.node.quasi.quasis.map(quasi => quasi.value.cooked).join('');\n let { compiled, dependencies } = compiler(state).precompile(template, { filename: state.file.opts.filename });\n for (let dep of dependencies) {\n state.dependencies.set(dep.runtimeName, dep);\n }\n\n path.replaceWith(\n t.callExpression(state.adder.import(path, '@ember/template-factory', 'createTemplateFactory'), [\n jsonLiteral(compiled, t),\n ])\n );\n }\n\n function handleCalled(path: NodePath<t.CallExpression>, state: State<O>, t: BabelTypes) {\n let { template, insertRuntimeErrors } = getCallArguments(path);\n let compilerInstance = compiler(state);\n\n let result: ReturnType<TemplateCompiler['precompile']>;\n try {\n result = compilerInstance.precompile(template, { filename: state.file.opts.filename, insertRuntimeErrors });\n } catch (err) {\n if (insertRuntimeErrors) {\n path.replaceWith(\n t.callExpression(\n t.functionExpression(\n null,\n [],\n t.blockStatement([\n t.throwStatement(t.newExpression(t.identifier('Error'), [t.stringLiteral(err.message)])),\n ])\n ),\n []\n )\n );\n return;\n }\n throw err;\n }\n let { compiled, dependencies } = result;\n for (let dep of dependencies) {\n state.dependencies.set(dep.runtimeName, dep);\n }\n path.replaceWith(\n t.callExpression(state.adder.import(path, '@ember/template-factory', 'createTemplateFactory'), [\n jsonLiteral(compiled, t),\n ])\n );\n }\n\n function jsonLiteral(value: unknown | undefined, t: BabelTypes) {\n if (typeof value === 'undefined') {\n return t.identifier('undefined');\n }\n let ast = parse(`a(${value})`, {}) as t.File;\n let statement = ast.program.body[0] as t.ExpressionStatement;\n let expression = statement.expression as t.CallExpression;\n return expression.arguments[0];\n }\n\n function compiler(state: State<O>) {\n if (!state.templateCompiler) {\n state.templateCompiler = getCompiler(state.opts);\n }\n return state.templateCompiler;\n }\n\n function amdDefine(runtimeName: string, importCounter: number, t: BabelTypes) {\n return t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier('window'), t.identifier('define')), [\n t.stringLiteral(runtimeName),\n t.functionExpression(null, [], t.blockStatement([t.returnStatement(t.identifier(`a${importCounter}`))])),\n ])\n );\n }\n\n function getTemplateString(template: any, path: NodePath<t.CallExpression>): string {\n if (template?.type === 'StringLiteral') {\n return template.value;\n }\n // treat inert TemplateLiteral (without subexpressions) like a StringLiteral\n if (template?.type === 'TemplateLiteral' && !template.expressions.length) {\n return template.quasis[0].value.cooked;\n }\n throw path.buildCodeFrameError('hbs accepts only a string literal argument');\n }\n\n function getCallArguments(path: NodePath<t.CallExpression>): { template: string; insertRuntimeErrors: boolean } {\n let [template, options] = path.node.arguments;\n\n let insertRuntimeErrors =\n options?.type === 'ObjectExpression' &&\n options.properties.some(\n prop =>\n prop.type === 'ObjectProperty' &&\n prop.computed === false &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'insertRuntimeErrors' &&\n prop.value.type === 'BooleanLiteral' &&\n prop.value.value\n );\n\n return {\n template: getTemplateString(template, path),\n insertRuntimeErrors,\n };\n }\n\n return inlineHBSTransform;\n}\n"]}
@@ -0,0 +1,12 @@
1
+ import { NodeTemplateCompilerParams } from './template-compiler-node';
2
+ export interface Params {
3
+ templateCompiler: NodeTemplateCompilerParams;
4
+ }
5
+ declare const _default: {
6
+ (babel: typeof import("@babel/core")): unknown;
7
+ _parallelBabel: {
8
+ requireFile: string;
9
+ };
10
+ baseDir(): string;
11
+ };
12
+ export default _default;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const template_compiler_node_1 = require("./template-compiler-node");
7
+ const babel_plugin_stage1_inline_hbs_1 = __importDefault(require("./babel-plugin-stage1-inline-hbs"));
8
+ exports.default = (0, babel_plugin_stage1_inline_hbs_1.default)((opts) => new template_compiler_node_1.NodeTemplateCompiler(opts.templateCompiler));
9
+ //# sourceMappingURL=babel-plugin-stage1-inline-hbs-node.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-stage1-inline-hbs-node.js","sourceRoot":"","sources":["babel-plugin-stage1-inline-hbs-node.ts"],"names":[],"mappings":";;;;;AAAA,qEAA4F;AAC5F,sGAAoD;AAMpD,kBAAe,IAAA,wCAAI,EAAC,CAAC,IAAY,EAAE,EAAE,CAAC,IAAI,6CAAoB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC","sourcesContent":["import { NodeTemplateCompiler, NodeTemplateCompilerParams } from './template-compiler-node';\nimport make from './babel-plugin-stage1-inline-hbs';\n\nexport interface Params {\n templateCompiler: NodeTemplateCompilerParams;\n}\n\nexport default make((opts: Params) => new NodeTemplateCompiler(opts.templateCompiler));\n"]}
@@ -0,0 +1,9 @@
1
+ import { TemplateCompiler } from './template-compiler-common';
2
+ import type * as Babel from '@babel/core';
3
+ export default function make<Opts>(getCompiler: (opts: Opts) => TemplateCompiler): {
4
+ (babel: typeof Babel): unknown;
5
+ _parallelBabel: {
6
+ requireFile: string;
7
+ };
8
+ baseDir(): string;
9
+ };
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ /*
3
+ This babel plugins is responsible for running custom AST transform in inline
4
+ templates. It doesn't compile to wire format, because it runs at stage1.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const path_1 = require("path");
8
+ const shared_internals_1 = require("@embroider/shared-internals");
9
+ function make(getCompiler) {
10
+ function stage1InlineHBSTransform(babel) {
11
+ let t = babel.types;
12
+ return {
13
+ visitor: {
14
+ TaggedTemplateExpression(path, state) {
15
+ for (let { module, exportedName } of shared_internals_1.templateCompilationModules) {
16
+ if (path.get('tag').referencesImport(module, exportedName)) {
17
+ handleTagged(path, state, t);
18
+ }
19
+ }
20
+ },
21
+ CallExpression(path, state) {
22
+ for (let { module, exportedName } of shared_internals_1.templateCompilationModules) {
23
+ if (path.get('callee').referencesImport(module, exportedName)) {
24
+ handleCalled(path, state, t);
25
+ }
26
+ }
27
+ },
28
+ },
29
+ };
30
+ }
31
+ stage1InlineHBSTransform._parallelBabel = {
32
+ requireFile: __filename,
33
+ };
34
+ stage1InlineHBSTransform.baseDir = function () {
35
+ return (0, path_1.join)(__dirname, '..');
36
+ };
37
+ function handleTagged(path, state, t) {
38
+ if (path.node.quasi.expressions.length) {
39
+ throw path.buildCodeFrameError('placeholders inside a tagged template string are not supported');
40
+ }
41
+ let template = path.node.quasi.quasis.map(quasi => quasi.value.cooked).join('');
42
+ let compiled = compiler(state).applyTransforms(state.file.opts.filename, template);
43
+ path.get('quasi').replaceWith(t.templateLiteral([t.templateElement({ raw: compiled, cooked: compiled })], []));
44
+ }
45
+ function handleCalled(path, state, t) {
46
+ let { template, insertRuntimeErrors } = getCallArguments(path);
47
+ let compilerInstance = compiler(state);
48
+ let compiled;
49
+ try {
50
+ compiled = compilerInstance.applyTransforms(state.file.opts.filename, template);
51
+ }
52
+ catch (err) {
53
+ if (insertRuntimeErrors) {
54
+ // in stage 1 we just leave the bad template in place (we were only
55
+ // trying to run transforms and re-emit hbs), so that it will be handled
56
+ // at stage3 instead.
57
+ return;
58
+ }
59
+ throw err;
60
+ }
61
+ path.get('arguments')[0].replaceWith(t.stringLiteral(compiled));
62
+ }
63
+ function compiler(state) {
64
+ if (!state.templateCompiler) {
65
+ state.templateCompiler = getCompiler(state.opts);
66
+ }
67
+ return state.templateCompiler;
68
+ }
69
+ function getCallArguments(path) {
70
+ let [template, options] = path.node.arguments;
71
+ let insertRuntimeErrors = (options === null || options === void 0 ? void 0 : options.type) === 'ObjectExpression' &&
72
+ options.properties.some(prop => prop.type === 'ObjectProperty' &&
73
+ prop.computed === false &&
74
+ prop.key.type === 'Identifier' &&
75
+ prop.key.name === 'insertRuntimeErrors' &&
76
+ prop.value.type === 'BooleanLiteral' &&
77
+ prop.value.value);
78
+ return {
79
+ template: getTemplateString(template, path),
80
+ insertRuntimeErrors,
81
+ };
82
+ }
83
+ return stage1InlineHBSTransform;
84
+ }
85
+ exports.default = make;
86
+ function getTemplateString(template, path) {
87
+ if ((template === null || template === void 0 ? void 0 : template.type) === 'StringLiteral') {
88
+ return template.value;
89
+ }
90
+ // treat inert TemplateLiteral (without subexpressions) like a StringLiteral
91
+ if ((template === null || template === void 0 ? void 0 : template.type) === 'TemplateLiteral' && !template.expressions.length) {
92
+ return template.quasis[0].value.cooked;
93
+ }
94
+ throw path.buildCodeFrameError('hbs accepts only a string literal argument');
95
+ }
96
+ //# sourceMappingURL=babel-plugin-stage1-inline-hbs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel-plugin-stage1-inline-hbs.js","sourceRoot":"","sources":["babel-plugin-stage1-inline-hbs.ts"],"names":[],"mappings":";AAAA;;;EAGE;;AAEF,+BAA4B;AAK5B,kEAAyE;AAEzE,SAAwB,IAAI,CAAO,WAA6C;IAY9E,SAAS,wBAAwB,CAAC,KAAmB;QACnD,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;QACpB,OAAO;YACL,OAAO,EAAE;gBACP,wBAAwB,CAAC,IAA0C,EAAE,KAAY;oBAC/E,KAAK,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,6CAA0B,EAAE;wBAC/D,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE;4BAC1D,YA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gBAAgB;gBAC9B,IAAI,CAAC,QAAQ,KAAK,KAAK;gBACvB,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,YAAY;gBAC9B,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,qBAAqB;gBACvC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,gBAAgB;gBACpC,IAAI,CAAC,KAAK,CAAC,KAAK,CACnB,CAAC;QAEJ,OAAO;YACL,QAAQ,EAAE,iBAAiB,CAAC,QAAQ,EAAE,IAAI,CAAC;YAC3C,mBAAmB;SACpB,CAAC;IACJ,CAAC;IAED,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAnGD,uBAmGC;AAED,SAAS,iBAAiB,CAAC,QAAa,EAAE,IAAgC;IACxE,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,eAAe,EAAE;QACtC,OAAO,QAAQ,CAAC,KAAK,CAAC;KACvB;IACD,4EAA4E;IAC5E,IAAI,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,MAAK,iBAAiB,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,EAAE;QACxE,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC;KACxC;IACD,MAAM,IAAI,CAAC,mBAAmB,CAAC,4CAA4C,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["/*\n This babel plugins is responsible for running custom AST transform in inline\n templates. It doesn't compile to wire format, because it runs at stage1.\n*/\n\nimport { join } from 'path';\nimport { TemplateCompiler } from './template-compiler-common';\nimport type { NodePath } from '@babel/traverse';\nimport type * as Babel from '@babel/core';\nimport type { types as t } from '@babel/core';\nimport { templateCompilationModules } from '@embroider/shared-internals';\n\nexport default function make<Opts>(getCompiler: (opts: Opts) => TemplateCompiler) {\n interface State {\n opts: Opts;\n file: {\n code: string;\n opts: {\n filename: string;\n };\n };\n templateCompiler: TemplateCompiler | undefined;\n }\n\n function stage1InlineHBSTransform(babel: typeof Babel): unknown {\n let t = babel.types;\n return {\n visitor: {\n TaggedTemplateExpression(path: NodePath<t.TaggedTemplateExpression>, state: State) {\n for (let { module, exportedName } of templateCompilationModules) {\n if (path.get('tag').referencesImport(module, exportedName)) {\n handleTagged(path, state, t);\n }\n }\n },\n CallExpression(path: NodePath<t.CallExpression>, state: State) {\n for (let { module, exportedName } of templateCompilationModules) {\n if (path.get('callee').referencesImport(module, exportedName)) {\n handleCalled(path, state, t);\n }\n }\n },\n },\n };\n }\n\n stage1InlineHBSTransform._parallelBabel = {\n requireFile: __filename,\n };\n\n stage1InlineHBSTransform.baseDir = function () {\n return join(__dirname, '..');\n };\n\n function handleTagged(path: NodePath<t.TaggedTemplateExpression>, state: State, t: typeof Babel.types) {\n if (path.node.quasi.expressions.length) {\n throw path.buildCodeFrameError('placeholders inside a tagged template string are not supported');\n }\n let template = path.node.quasi.quasis.map(quasi => quasi.value.cooked).join('');\n let compiled = compiler(state).applyTransforms(state.file.opts.filename, template);\n path.get('quasi').replaceWith(t.templateLiteral([t.templateElement({ raw: compiled, cooked: compiled })], []));\n }\n\n function handleCalled(path: NodePath<t.CallExpression>, state: State, t: typeof Babel.types) {\n let { template, insertRuntimeErrors } = getCallArguments(path);\n let compilerInstance = compiler(state);\n\n let compiled: string;\n try {\n compiled = compilerInstance.applyTransforms(state.file.opts.filename, template);\n } catch (err) {\n if (insertRuntimeErrors) {\n // in stage 1 we just leave the bad template in place (we were only\n // trying to run transforms and re-emit hbs), so that it will be handled\n // at stage3 instead.\n return;\n }\n throw err;\n }\n (path.get('arguments')[0] as NodePath).replaceWith(t.stringLiteral(compiled));\n }\n\n function compiler(state: State) {\n if (!state.templateCompiler) {\n state.templateCompiler = getCompiler(state.opts);\n }\n return state.templateCompiler;\n }\n\n function getCallArguments(path: NodePath<t.CallExpression>): { template: string; insertRuntimeErrors: boolean } {\n let [template, options] = path.node.arguments;\n\n let insertRuntimeErrors =\n options?.type === 'ObjectExpression' &&\n options.properties.some(\n prop =>\n prop.type === 'ObjectProperty' &&\n prop.computed === false &&\n prop.key.type === 'Identifier' &&\n prop.key.name === 'insertRuntimeErrors' &&\n prop.value.type === 'BooleanLiteral' &&\n prop.value.value\n );\n\n return {\n template: getTemplateString(template, path),\n insertRuntimeErrors,\n };\n }\n\n return stage1InlineHBSTransform;\n}\n\nfunction getTemplateString(template: any, path: NodePath<t.CallExpression>): string {\n if (template?.type === 'StringLiteral') {\n return template.value;\n }\n // treat inert TemplateLiteral (without subexpressions) like a StringLiteral\n if (template?.type === 'TemplateLiteral' && !template.expressions.length) {\n return template.quasis[0].value.cooked;\n }\n throw path.buildCodeFrameError('hbs accepts only a string literal argument');\n}\n"]}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.describeExports = void 0;
7
7
  const core_1 = require("@babel/core");
8
8
  const traverse_1 = __importDefault(require("@babel/traverse"));
9
- const types_1 = require("@babel/types");
9
+ const core_2 = require("@babel/core");
10
10
  const assert_never_1 = __importDefault(require("assert-never"));
11
11
  function describeExports(code, babelParserConfig) {
12
12
  let ast = (0, core_1.parse)(code, babelParserConfig);
@@ -36,9 +36,9 @@ function describeExports(code, babelParserConfig) {
36
36
  (0, assert_never_1.default)(spec);
37
37
  }
38
38
  }
39
- if ((0, types_1.isVariableDeclaration)(path.node.declaration)) {
39
+ if (core_2.types.isVariableDeclaration(path.node.declaration)) {
40
40
  for (let dec of path.node.declaration.declarations) {
41
- if ((0, types_1.isIdentifier)(dec.id)) {
41
+ if (core_2.types.isIdentifier(dec.id)) {
42
42
  names.add(dec.id.name);
43
43
  }
44
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"describe-exports.js","sourceRoot":"","sources":["describe-exports.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAsD;AACtD,+DAAqD;AACrD,wCAAqH;AACrH,gEAAuC;AAEvC,SAAgB,eAAe,CAC7B,IAAY,EACZ,iBAAmC;IAEnC,I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BACxB;iBACF;aACF;QACH,CAAC;QACD,wBAAwB,CAAC,KAAyC;YAChE,gBAAgB,GAAG,IAAI,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;AACrC,CAAC;AA7CD,0CA6CC","sourcesContent":["import { parse, TransformOptions } from '@babel/core';\nimport traverse, { NodePath } from '@babel/traverse';\nimport { ExportNamedDeclaration, ExportDefaultDeclaration, isVariableDeclaration, isIdentifier } from '@babel/types';\nimport assertNever from 'assert-never';\n\nexport function describeExports(\n code: string,\n babelParserConfig: TransformOptions\n): { names: Set<string>; hasDefaultExport: boolean } {\n let ast = parse(code, babelParserConfig);\n if (!ast || ast.type !== 'File') {\n throw new Error(`bug in embroider/core describe-exports`);\n }\n let names: Set<string> = new Set();\n let hasDefaultExport = false;\n\n traverse(ast, {\n ExportNamedDeclaration(path: NodePath<ExportNamedDeclaration>) {\n for (let spec of path.node.specifiers) {\n switch (spec.type) {\n case 'ExportSpecifier':\n case 'ExportNamespaceSpecifier':\n const name = spec.exported.type === 'Identifier' ? spec.exported.name : spec.exported.value;\n\n if (name === 'default') {\n hasDefaultExport = true;\n } else {\n names.add(name);\n }\n break;\n case 'ExportDefaultSpecifier':\n // this is in the types but was never standardized\n break;\n default:\n assertNever(spec);\n }\n }\n if (isVariableDeclaration(path.node.declaration)) {\n for (let dec of path.node.declaration.declarations) {\n if (isIdentifier(dec.id)) {\n names.add(dec.id.name);\n }\n }\n }\n },\n ExportDefaultDeclaration(_path: NodePath<ExportDefaultDeclaration>) {\n hasDefaultExport = true;\n },\n });\n return { names, hasDefaultExport };\n}\n"]}
1
+ {"version":3,"file":"describe-exports.js","sourceRoot":"","sources":["describe-exports.ts"],"names":[],"mappings":";;;;;;AAAA,sCAAsD;AACtD,+DAAqD;AACrD,sCAAyC;AACzC,gEAAuC;AAEvC,SAAgB,eAAe,CAC7B,IAAY,EACZ,iBAAmC;IAEnC,IAAI,GAAG,GAA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xB;iBACF;aACF;QACH,CAAC;QACD,wBAAwB,CAAC,KAA2C;YAClE,gBAAgB,GAAG,IAAI,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;IACH,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;AACrC,CAAC;AA7CD,0CA6CC","sourcesContent":["import { parse, TransformOptions } from '@babel/core';\nimport traverse, { NodePath } from '@babel/traverse';\nimport { types as t } from '@babel/core';\nimport assertNever from 'assert-never';\n\nexport function describeExports(\n code: string,\n babelParserConfig: TransformOptions\n): { names: Set<string>; hasDefaultExport: boolean } {\n let ast = parse(code, babelParserConfig);\n if (!ast || ast.type !== 'File') {\n throw new Error(`bug in embroider/core describe-exports`);\n }\n let names: Set<string> = new Set();\n let hasDefaultExport = false;\n\n traverse(ast, {\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\n for (let spec of path.node.specifiers) {\n switch (spec.type) {\n case 'ExportSpecifier':\n case 'ExportNamespaceSpecifier':\n const name = spec.exported.type === 'Identifier' ? spec.exported.name : spec.exported.value;\n\n if (name === 'default') {\n hasDefaultExport = true;\n } else {\n names.add(name);\n }\n break;\n case 'ExportDefaultSpecifier':\n // this is in the types but was never standardized\n break;\n default:\n assertNever(spec);\n }\n }\n if (t.isVariableDeclaration(path.node.declaration)) {\n for (let dec of path.node.declaration.declarations) {\n if (t.isIdentifier(dec.id)) {\n names.add(dec.id.name);\n }\n }\n }\n },\n ExportDefaultDeclaration(_path: NodePath<t.ExportDefaultDeclaration>) {\n hasDefaultExport = true;\n },\n });\n return { names, hasDefaultExport };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type * as t from '@babel/types';
1
+ import type { types as t } from '@babel/core';
2
2
  import type { NodePath } from '@babel/traverse';
3
3
  declare type BabelTypes = typeof t;
4
4
  export default function miniModulesPolyfill(babel: unknown): {
@@ -1 +1 @@
1
- {"version":3,"file":"mini-modules-polyfill.js","sourceRoot":"","sources":["mini-modules-polyfill.ts"],"names":[],"mapp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,EAAE;oBACZ,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC5G,SAAS,CAAC,MAAM,EAAE,CAAC;iBACpB;aACF;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAtBD,0DAsBC","sourcesContent":["import type * as t from '@babel/types';\nimport type { NodePath } from '@babel/traverse';\n\ntype BabelTypes = typeof t;\n\n// this is intentionally not the whole babel-plugin-ember-modules-api-polyfill.\n// That runs very early, so any usage of polyfilled imports that gets emitted by\n// our other babel plugins can't take advantage of it.\n//\n// If I was going to try to do this properly, I would change\n// babel-plugin-ember-modules-api-polyfill to run very late in the game, like\n// this code does, so that other plugins could always not worry about it. But\n// seeing as modules-api-polyfill is already on the way out, it's simpler to\n// just handle the small piece of its functionality that matter to us:\n//\n// - all our usage (emitted by our babel plugins) is static imports, not dynamic\n// ones, so it's OK to just walk the top level, saving us the cost of a full\n// traverse\n// - we only emit a handful of specific imports that are easy to just list here\n//\n//\nlet replacements: { [moduleSpecifier: string]: { [name: string]: ((t: BabelTypes) => t.Expression) | undefined } } = {\n '@ember/component/template-only': {\n default(t: BabelTypes) {\n return t.memberExpression(t.identifier('Ember'), t.identifier('_templateOnlyComponent'));\n },\n },\n '@ember/template-factory': {\n createTemplateFactory(t) {\n return t.memberExpression(\n t.memberExpression(t.identifier('Ember'), t.identifier('HTMLBars')),\n t.identifier('template')\n );\n },\n },\n '@ember/component': {\n default(t: BabelTypes) {\n return t.memberExpression(t.identifier('Ember'), t.identifier('Component'));\n },\n setComponentTemplate(t: BabelTypes) {\n return t.memberExpression(t.identifier('Ember'), t.identifier('_setComponentTemplate'));\n },\n },\n};\n\nexport default function miniModulesPolyfill(babel: unknown) {\n let t = (babel as any).types as BabelTypes;\n return {\n visitor: {\n Program: {\n exit(path: NodePath<t.Program>) {\n for (let child of path.get('body')) {\n if (child.isImportDeclaration()) {\n let replacement = handleImportDeclaration(t, child);\n if (replacement) {\n path.replaceWith(replacement);\n }\n }\n }\n },\n },\n },\n };\n}\n\nexport function handleImportDeclaration(t: BabelTypes, path: NodePath<t.ImportDeclaration>) {\n let match = replacements[path.node.source.value];\n if (match) {\n let specifiers = path.get('specifiers');\n let replacers = specifiers.map(specifier => ({ replacer: match[specifier.node.local.name], specifier }));\n if (replacers.every(r => Boolean(r.replacer))) {\n path.replaceWith(\n t.variableDeclaration(\n 'const',\n replacers.map(r => t.variableDeclarator(r.specifier.node.local, r.replacer!(t)))\n )\n );\n } else {\n for (let { specifier, replacer } of replacers) {\n if (replacer) {\n path.insertAfter(t.variableDeclaration('const', [t.variableDeclarator(specifier.node.local, replacer(t))]));\n specifier.remove();\n }\n }\n }\n }\n return undefined;\n}\n"]}
1
+ {"version":3,"file":"mini-modules-polyfill.js","sourceRoot":"","sources":["mini-modules-polyfill.ts"],"names":[],"mappings":";;;AAKA,+EAA+E;AAC/E,gFAAgF;AAChF,sDAAsD;AACtD,EAAE;AACF,4DAA4D;AAC5D,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC5E,sEAAsE;AACtE,EAAE;AACF,gFAAgF;AAChF,8EAA8E;AAC9E,aAAa;AACb,+EAA+E;AAC/E,EAAE;AACF,EAAE;AACF,IAAI,YAAY,GAAqG;IACnH,gCAAgC,EAAE;QAChC,OAAO,CAAC,CAAa;YACnB,OAAO,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,wBAAwB,CAAC,CAAC,CAAC;QAC3F,CAAC;KACF;IACD,yBAAyB,EAAE;QACzB,qBAAqB,CAAC,CAAC;YACrB,OAAO,CAAC,CAAC,gBAAgB,CACvB,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,CAAC,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,IAAI,SAAS,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;QACzG,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE;YAC7C,IAAI,CAAC,WAAW,CACd,CAAC,CAAC,mBAAmB,CACnB,OAAO,EACP,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,QAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CACjF,CACF,CAAC;SACH;aAAM;YACL,KAAK,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,SAAS,EAAE;gBAC7C,IAAI,QAAQ,EAAE;oBACZ,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,kBAAkB,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAC5G,SAAS,CAAC,MAAM,EAAE,CAAC;iBACpB;aACF;SACF;KACF;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAtBD,0DAsBC","sourcesContent":["import type { types as t } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\n\ntype BabelTypes = typeof t;\n\n// this is intentionally not the whole babel-plugin-ember-modules-api-polyfill.\n// That runs very early, so any usage of polyfilled imports that gets emitted by\n// our other babel plugins can't take advantage of it.\n//\n// If I was going to try to do this properly, I would change\n// babel-plugin-ember-modules-api-polyfill to run very late in the game, like\n// this code does, so that other plugins could always not worry about it. But\n// seeing as modules-api-polyfill is already on the way out, it's simpler to\n// just handle the small piece of its functionality that matter to us:\n//\n// - all our usage (emitted by our babel plugins) is static imports, not dynamic\n// ones, so it's OK to just walk the top level, saving us the cost of a full\n// traverse\n// - we only emit a handful of specific imports that are easy to just list here\n//\n//\nlet replacements: { [moduleSpecifier: string]: { [name: string]: ((t: BabelTypes) => t.Expression) | undefined } } = {\n '@ember/component/template-only': {\n default(t: BabelTypes) {\n return t.memberExpression(t.identifier('Ember'), t.identifier('_templateOnlyComponent'));\n },\n },\n '@ember/template-factory': {\n createTemplateFactory(t) {\n return t.memberExpression(\n t.memberExpression(t.identifier('Ember'), t.identifier('HTMLBars')),\n t.identifier('template')\n );\n },\n },\n '@ember/component': {\n default(t: BabelTypes) {\n return t.memberExpression(t.identifier('Ember'), t.identifier('Component'));\n },\n setComponentTemplate(t: BabelTypes) {\n return t.memberExpression(t.identifier('Ember'), t.identifier('_setComponentTemplate'));\n },\n },\n};\n\nexport default function miniModulesPolyfill(babel: unknown) {\n let t = (babel as any).types as BabelTypes;\n return {\n visitor: {\n Program: {\n exit(path: NodePath<t.Program>) {\n for (let child of path.get('body')) {\n if (child.isImportDeclaration()) {\n let replacement = handleImportDeclaration(t, child);\n if (replacement) {\n path.replaceWith(replacement);\n }\n }\n }\n },\n },\n },\n };\n}\n\nexport function handleImportDeclaration(t: BabelTypes, path: NodePath<t.ImportDeclaration>) {\n let match = replacements[path.node.source.value];\n if (match) {\n let specifiers = path.get('specifiers');\n let replacers = specifiers.map(specifier => ({ replacer: match[specifier.node.local.name], specifier }));\n if (replacers.every(r => Boolean(r.replacer))) {\n path.replaceWith(\n t.variableDeclaration(\n 'const',\n replacers.map(r => t.variableDeclarator(r.specifier.node.local, r.replacer!(t)))\n )\n );\n } else {\n for (let { specifier, replacer } of replacers) {\n if (replacer) {\n path.insertAfter(t.variableDeclaration('const', [t.variableDeclarator(specifier.node.local, replacer(t))]));\n specifier.remove();\n }\n }\n }\n }\n return undefined;\n}\n"]}
package/src/options.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export default interface Options {
2
2
  staticHelpers?: boolean;
3
+ staticModifiers?: boolean;
3
4
  staticComponents?: boolean;
4
5
  splitAtRoutes?: (RegExp | string)[];
5
6
  staticAppPaths?: string[];
package/src/options.js CHANGED
@@ -4,6 +4,7 @@ exports.optionsWithDefaults = void 0;
4
4
  function optionsWithDefaults(options) {
5
5
  let defaults = {
6
6
  staticHelpers: false,
7
+ staticModifiers: false,
7
8
  staticComponents: false,
8
9
  packageRules: [],
9
10
  splitAtRoutes: [],
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AAmGA,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,IAAI,QAAQ,GAAG;QACb,aAAa,EAAE,KAAK;QACpB,gBAAgB,EAAE,KAAK;QACvB,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE,EAAE;QACjB,gBAAgB,EAAE,KAAK;QACvB,iBAAiB,EAAE,KAAK;QACxB,cAAc,EAAE,EAAE;QAClB,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,EAAE;QACf,uBAAuB,EAAE,eAAkC;KAC5D,CAAC;IACF,IAAI,OAAO,EAAE;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KACzC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAjBD,kDAiBC","sourcesContent":["export default interface Options {\n // When true, we statically resolve all template helpers at build time. This\n // causes unused helpers to be left out of the build (\"tree shaking\" of\n // helpers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticHelpers?: boolean;\n\n // When true, we statically resolve all components at build time. This causes\n // unused components to be left out of the build (\"tree shaking\" of\n // components).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticComponents?: boolean;\n\n // Enables per-route code splitting. Any route names that match these patterns\n // will be split out of the initial app payload. If you use this, you must\n // also add @embroider/router to your app. See [@embroider/router's\n // README](https://github.com/embroider-build/embroider/blob/master/packages/router/README.md)\n splitAtRoutes?: (RegExp | string)[];\n\n // Every file within your application's `app` directory is categorized as a\n // component, helper, route, route template, controller, or \"other\".\n //\n // This option lets you decide which \"other\" files should be loaded\n // statically. By default, all \"other\" files will be included in the build and\n // registered with Ember's runtime loader, because we can't know if somebody\n // is going to try to access them dynamically via Ember's resolver or AMD\n // runtime `require`.\n //\n // If you know that your files are only ever imported, you can list them here\n // and then they will only be included exactly where they're needed.\n //\n // Provide a list of directories or files relative to `/app`. For example\n //\n // staticAppPaths: ['lib']\n //\n // means that everything under your-project/app/lib will be loaded statically.\n //\n // This option has no effect on components (which are governed by\n // staticComponents), helpers (which are governed by staticHelpers), or the\n // route-specific files (routes, route templates, and controllers which are\n // governed by splitAtRoutes).\n staticAppPaths?: string[];\n\n // By default, all modules that get imported into the app go through Babel, so\n // that all code will conform with your Babel targets. This option allows you\n // to turn Babel off for a particular package. You might need this to work\n // around a transpiler bug or you might use this as a build-performance\n // optimization if you've manually verified that a particular package doesn't\n // need transpilation to be safe in your target browsers.\n skipBabel?: { package: string; semverRange?: string }[];\n\n // This is a performance optimization that can help you avoid the \"Your build\n // is slower because some babel plugins are non-serializable\" penalty. If you\n // provide the locations of known non-serializable objects, we can discover\n // them and make them serializable.\n //\n // resolve is a list of paths to resolve, in a chain. This lets you resolve\n // your dependencies' dependencies, like: resolve: ['your-dependency',\n // 'inner-dependency/lib/transform']\n //\n // useMethod optionally lets you pick which property within the module to use.\n // If not provided, we use the module.exports itself.\n pluginHints?: { resolve: string[]; useMethod?: string }[];\n\n // Our addons' implicit-modules and implicit-test-modules are not necessarily\n // resolvable directly from the app, but the meaning of those\n // backward-compatibility features is \"the app should import this module\". So\n // we need some strategy for making them importable by the app. We can either\n // turn those imports into complete relative paths, or leave them as package\n // names:\n //\n // relativePaths:\n //\n // import('./node_modules/intermediate/node_modules/some-addon/thing.js')\n //\n // packageNames:\n //\n // import('some-addon/thing.js')\n //\n // When building under a tool like webpack, the relativePaths are safe and\n // always work, although they can be uglier to look at when debugging in\n // development.\n //\n // When building under a tool like snowpack, the package names can be easier\n // to work with because you already have web-bundles per package, and can't\n // necessarily address arbitrary places on the filesystem.\n //\n // Defaults to \"relativePaths\".\n implicitModulesStrategy?: 'packageNames' | 'relativePaths';\n}\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n let defaults = {\n staticHelpers: false,\n staticComponents: false,\n packageRules: [],\n splitAtRoutes: [],\n splitControllers: false,\n splitRouteClasses: false,\n staticAppPaths: [],\n skipBabel: [],\n pluginHints: [],\n implicitModulesStrategy: 'relativePaths' as 'relativePaths',\n };\n if (options) {\n return Object.assign(defaults, options);\n }\n return defaults;\n}\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AA6GA,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,IAAI,QAAQ,GAAG;QACb,aAAa,EAAE,KAAK;QACpB,eAAe,EAAE,KAAK;QACtB,gBAAgB,EAAE,KAAK;QACvB,YAAY,EAAE,EAAE;QAChB,aAAa,EAAE,EAAE;QACjB,gBAAgB,EAAE,KAAK;QACvB,iBAAiB,EAAE,KAAK;QACxB,cAAc,EAAE,EAAE;QAClB,SAAS,EAAE,EAAE;QACb,WAAW,EAAE,EAAE;QACf,uBAAuB,EAAE,eAAkC;KAC5D,CAAC;IACF,IAAI,OAAO,EAAE;QACX,OAAO,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KACzC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAlBD,kDAkBC","sourcesContent":["export default interface Options {\n // When true, we statically resolve all template helpers at build time. This\n // causes unused helpers to be left out of the build (\"tree shaking\" of\n // helpers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticHelpers?: boolean;\n\n // When true, we statically resolve all modifiers at build time. This\n // causes unused modifiers to be left out of the build (\"tree shaking\" of\n // modifiers).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticModifiers?: boolean;\n\n // When true, we statically resolve all components at build time. This causes\n // unused components to be left out of the build (\"tree shaking\" of\n // components).\n //\n // Defaults to false, which gives you greater compatibility with classic Ember\n // apps at the cost of bigger builds.\n //\n // Enabling this is a prerequisite for route splitting.\n staticComponents?: boolean;\n\n // Enables per-route code splitting. Any route names that match these patterns\n // will be split out of the initial app payload. If you use this, you must\n // also add @embroider/router to your app. See [@embroider/router's\n // README](https://github.com/embroider-build/embroider/blob/master/packages/router/README.md)\n splitAtRoutes?: (RegExp | string)[];\n\n // Every file within your application's `app` directory is categorized as a\n // component, helper, modifier, route, route template, controller, or \"other\".\n //\n // This option lets you decide which \"other\" files should be loaded\n // statically. By default, all \"other\" files will be included in the build and\n // registered with Ember's runtime loader, because we can't know if somebody\n // is going to try to access them dynamically via Ember's resolver or AMD\n // runtime `require`.\n //\n // If you know that your files are only ever imported, you can list them here\n // and then they will only be included exactly where they're needed.\n //\n // Provide a list of directories or files relative to `/app`. For example\n //\n // staticAppPaths: ['lib']\n //\n // means that everything under your-project/app/lib will be loaded statically.\n //\n // This option has no effect on components (which are governed by\n // staticComponents), helpers (which are governed by staticHelpers), modifiers\n // (which are governed by staticModifiers) or the route-specific files (routes,\n // route templates, and controllers which are governed by splitAtRoutes).\n staticAppPaths?: string[];\n\n // By default, all modules that get imported into the app go through Babel, so\n // that all code will conform with your Babel targets. This option allows you\n // to turn Babel off for a particular package. You might need this to work\n // around a transpiler bug or you might use this as a build-performance\n // optimization if you've manually verified that a particular package doesn't\n // need transpilation to be safe in your target browsers.\n skipBabel?: { package: string; semverRange?: string }[];\n\n // This is a performance optimization that can help you avoid the \"Your build\n // is slower because some babel plugins are non-serializable\" penalty. If you\n // provide the locations of known non-serializable objects, we can discover\n // them and make them serializable.\n //\n // resolve is a list of paths to resolve, in a chain. This lets you resolve\n // your dependencies' dependencies, like: resolve: ['your-dependency',\n // 'inner-dependency/lib/transform']\n //\n // useMethod optionally lets you pick which property within the module to use.\n // If not provided, we use the module.exports itself.\n pluginHints?: { resolve: string[]; useMethod?: string }[];\n\n // Our addons' implicit-modules and implicit-test-modules are not necessarily\n // resolvable directly from the app, but the meaning of those\n // backward-compatibility features is \"the app should import this module\". So\n // we need some strategy for making them importable by the app. We can either\n // turn those imports into complete relative paths, or leave them as package\n // names:\n //\n // relativePaths:\n //\n // import('./node_modules/intermediate/node_modules/some-addon/thing.js')\n //\n // packageNames:\n //\n // import('some-addon/thing.js')\n //\n // When building under a tool like webpack, the relativePaths are safe and\n // always work, although they can be uglier to look at when debugging in\n // development.\n //\n // When building under a tool like snowpack, the package names can be easier\n // to work with because you already have web-bundles per package, and can't\n // necessarily address arbitrary places on the filesystem.\n //\n // Defaults to \"relativePaths\".\n implicitModulesStrategy?: 'packageNames' | 'relativePaths';\n}\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n let defaults = {\n staticHelpers: false,\n staticModifiers: false,\n staticComponents: false,\n packageRules: [],\n splitAtRoutes: [],\n splitControllers: false,\n splitRouteClasses: false,\n staticAppPaths: [],\n skipBabel: [],\n pluginHints: [],\n implicitModulesStrategy: 'relativePaths' as 'relativePaths',\n };\n if (options) {\n return Object.assign(defaults, options);\n }\n return defaults;\n}\n"]}
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.patch = void 0;
4
- const types_1 = require("@babel/types");
5
4
  const core_1 = require("@babel/core");
6
5
  function parseVersion(templateCompilerPath, source) {
7
6
  // ember-template-compiler.js contains a comment that indicates what version it is for
@@ -123,9 +122,9 @@ function patch(source, templateCompilerPath) {
123
122
  // the place we want is the only if with a computed member
124
123
  // expression predicate.
125
124
  if (test.isMemberExpression() && test.node.computed) {
126
- path.node.alternate = (0, types_1.ifStatement)((0, types_1.memberExpression)((0, types_1.identifier)('ast'), (0, types_1.identifier)('selfClosing')), (0, types_1.blockStatement)([
127
- (0, types_1.expressionStatement)((0, types_1.callExpression)((0, types_1.memberExpression)((0, types_1.identifier)('output'), (0, types_1.identifier)('push')), [
128
- (0, types_1.stringLiteral)(' />'),
125
+ path.node.alternate = core_1.types.ifStatement(core_1.types.memberExpression(core_1.types.identifier('ast'), core_1.types.identifier('selfClosing')), core_1.types.blockStatement([
126
+ core_1.types.expressionStatement(core_1.types.callExpression(core_1.types.memberExpression(core_1.types.identifier('output'), core_1.types.identifier('push')), [
127
+ core_1.types.stringLiteral(' />'),
129
128
  ])),
130
129
  ]), path.node.alternate);
131
130
  }
@@ -1 +1 @@
1
- {"version":3,"file":"patch-template-compiler.js","sourceRoot":"","sources":["patch-template-compiler.ts"],"names":[],"mappings":";;;AAAA,wCAasB;AAEtB,sCAAwC;AAExC,SAAS,YAAY,CAAC,oBAA4B,EAAE,MAAc;IAChE,sFAAsF;IACtF,mBAAmB;IAEnB;;;;;;;;OAQG;IAEH,IAAI,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACnD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;QAC3B,MAAM,IAAI,KAAK,CACb,sCAAsC,oBAAoB,uDAAuD,CAClH,CAAC;KACH;IAED,IAAI,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrC,IAAI,KAAK,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,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,sBA+JC","sourcesContent":["import {\n CallExpression,\n FunctionDeclaration,\n VariableDeclarator,\n SwitchCase,\n IfStatement,\n ifStatement,\n memberExpression,\n identifier,\n blockStatement,\n callExpression,\n expressionStatement,\n stringLiteral,\n} from '@babel/types';\nimport { NodePath } from '@babel/traverse';\nimport { transform } from '@babel/core';\n\nfunction parseVersion(templateCompilerPath: string, source: string): { major: number; minor: number; patch: number } {\n // ember-template-compiler.js contains a comment that indicates what version it is for\n // that looks like:\n\n /*!\n * @overview Ember - JavaScript Application Framework\n * @copyright Copyright 2011-2020 Tilde Inc. and contributors\n * Portions Copyright 2006-2011 Strobe Inc.\n * Portions Copyright 2008-2011 Apple Inc. All rights reserved.\n * @license Licensed under MIT license\n * See https://raw.github.com/emberjs/ember.js/master/LICENSE\n * @version 3.25.1\n */\n\n let version = source.match(/@version\\s+([\\d\\.]+)/);\n if (!version || !version[1]) {\n throw new Error(\n `Could not find version string in \\`${templateCompilerPath}\\`. Maybe we don't support your ember-source version?`\n );\n }\n\n let numbers = version[1].split('.');\n let major = parseInt(numbers[0], 10);\n let minor = parseInt(numbers[1], 10);\n let patch = parseInt(numbers[2], 10);\n\n return { major, minor, patch };\n}\n\nfunction emberVersionGte(templateCompilerPath: string, source: string, major: number, minor: number): boolean {\n let actual = parseVersion(templateCompilerPath, source);\n\n return actual.major > major || (actual.major === major && actual.minor >= minor);\n}\n\nexport function patch(source: string, templateCompilerPath: string): string {\n let version = parseVersion(templateCompilerPath, source);\n\n if (\n emberVersionGte(templateCompilerPath, source, 3, 26) ||\n (version.major === 3 && version.minor === 25 && version.patch >= 2) ||\n (version.major === 3 && version.minor === 24 && version.patch >= 3)\n ) {\n // no modifications are needed after\n // https://github.com/emberjs/ember.js/pull/19426 and backported to\n // 3.26.0-beta.3, 3.25.2, 3.24.3\n return source;\n }\n\n let replacedVar = false;\n let patchedSource;\n\n let needsAngleBracketPrinterFix =\n emberVersionGte(templateCompilerPath, source, 3, 12) && !emberVersionGte(templateCompilerPath, source, 3, 17);\n\n if (needsAngleBracketPrinterFix) {\n // here we are stripping off the first `var Ember;`. That one small change\n // lets us crack open the file and get access to its internal loader, because\n // we can give it our own predefined `Ember` variable instead, which it will\n // use and put `Ember.__loader` onto.\n //\n // on ember 3.12 through 3.16 (which use variants of glimmer-vm 0.38.5) we\n // also apply a patch to the printer in @glimmer/syntax to fix\n // https://github.com/glimmerjs/glimmer-vm/pull/941/files because it can\n // really bork apps under embroider, and we'd like to support at least all\n // active LTS versions of ember.\n patchedSource = transform(source, {\n plugins: [\n function () {\n return {\n visitor: {\n VariableDeclarator(path: NodePath<VariableDeclarator>) {\n let id = path.node.id;\n if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {\n replacedVar = true;\n path.remove();\n }\n },\n CallExpression: {\n enter(path: NodePath<CallExpression>, state: BabelState) {\n let callee = path.get('callee');\n if (!callee.isIdentifier() || callee.node.name !== 'define') {\n return;\n }\n let firstArg = path.get('arguments')[0];\n if (!firstArg.isStringLiteral() || firstArg.node.value !== '@glimmer/syntax') {\n return;\n }\n state.definingGlimmerSyntax = path;\n },\n exit(path: NodePath<CallExpression>, state: BabelState) {\n if (state.definingGlimmerSyntax === path) {\n state.definingGlimmerSyntax = false;\n }\n },\n },\n FunctionDeclaration: {\n enter(path: NodePath<FunctionDeclaration>, state: BabelState) {\n if (!state.definingGlimmerSyntax) {\n return;\n }\n let id = path.get('id');\n if (id.isIdentifier() && id.node.name === 'build') {\n state.declaringBuildFunction = path;\n }\n },\n exit(path: NodePath<FunctionDeclaration>, state: BabelState) {\n if (state.declaringBuildFunction === path) {\n state.declaringBuildFunction = false;\n }\n },\n },\n SwitchCase: {\n enter(path: NodePath<SwitchCase>, state: BabelState) {\n if (!state.definingGlimmerSyntax) {\n return;\n }\n let test = path.get('test');\n if (test.isStringLiteral() && test.node.value === 'ElementNode') {\n state.caseElementNode = path;\n }\n },\n exit(path: NodePath<SwitchCase>, state: BabelState) {\n if (state.caseElementNode === path) {\n state.caseElementNode = false;\n }\n },\n },\n IfStatement(path: NodePath<IfStatement>, state: BabelState) {\n if (!state.caseElementNode) {\n return;\n }\n let test = path.get('test');\n // the place we want is the only if with a computed member\n // expression predicate.\n if (test.isMemberExpression() && test.node.computed) {\n path.node.alternate = ifStatement(\n memberExpression(identifier('ast'), identifier('selfClosing')),\n blockStatement([\n expressionStatement(\n callExpression(memberExpression(identifier('output'), identifier('push')), [\n stringLiteral(' />'),\n ])\n ),\n ]),\n path.node.alternate\n );\n }\n },\n },\n };\n },\n ],\n })!.code!;\n } else {\n // applies to < 3.12 and >= 3.17\n //\n // here we are stripping off the first `var Ember;`. That one small change\n // lets us crack open the file and get access to its internal loader, because\n // we can give it our own predefined `Ember` variable instead, which it will\n // use and put `Ember.__loader` onto.\n patchedSource = transform(source, {\n generatorOpts: {\n compact: true,\n },\n plugins: [\n function () {\n return {\n visitor: {\n VariableDeclarator(path: NodePath<VariableDeclarator>) {\n let id = path.node.id;\n if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {\n replacedVar = true;\n path.remove();\n }\n },\n },\n };\n },\n ],\n })!.code!;\n }\n\n if (!replacedVar) {\n throw new Error(\n `didn't find expected source in ${templateCompilerPath}. Maybe we don't support your ember-source version?`\n );\n }\n\n return `\n let Ember = {};\n ${patchedSource};\n module.exports.Ember = Ember;\n `;\n}\n\ninterface BabelState {\n definingGlimmerSyntax: NodePath | false;\n declaringBuildFunction: NodePath | false;\n caseElementNode: NodePath | false;\n}\n"]}
1
+ {"version":3,"file":"patch-template-compiler.js","sourceRoot":"","sources":["patch-template-compiler.ts"],"names":[],"mappings":";;;AACA,sCAAoD;AAEpD,SAAS,YAAY,CAAC,oBAA4B,EAAE,MAAc;IAChE,sFAAsF;IACtF,mBAAmB;IAEnB;;;;;;;;OAQG;IAEH,IAAI,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACnD,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAA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,IAAI,CAAC,EAAE,CAAC;gCACtB,IAAI,EAAE,CAAC,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC,IAAI,KAAK,OAAO,IAAI,CAAC,WAAW,EAAE;oCACnE,WAAW,GAAG,IAAI,CAAC;oCACnB,IAAI,CAAC,MAAM,EAAE,CAAC;iCACf;4BACH,CAAC;yBACF;qBACF,CAAC;gBACJ,CAAC;aACF;SACF,CAAE,CAAC,IAAK,CAAC;KACX;IAED,IAAI,CAAC,WAAW,EAAE;QAChB,MAAM,IAAI,KAAK,CACb,kCAAkC,oBAAoB,qDAAqD,CAC5G,CAAC;KACH;IAED,OAAO;;QAED,aAAa;;GAElB,CAAC;AACJ,CAAC;AA/JD,sBA+JC","sourcesContent":["import { NodePath } from '@babel/traverse';\nimport { transform, types as t } from '@babel/core';\n\nfunction parseVersion(templateCompilerPath: string, source: string): { major: number; minor: number; patch: number } {\n // ember-template-compiler.js contains a comment that indicates what version it is for\n // that looks like:\n\n /*!\n * @overview Ember - JavaScript Application Framework\n * @copyright Copyright 2011-2020 Tilde Inc. and contributors\n * Portions Copyright 2006-2011 Strobe Inc.\n * Portions Copyright 2008-2011 Apple Inc. All rights reserved.\n * @license Licensed under MIT license\n * See https://raw.github.com/emberjs/ember.js/master/LICENSE\n * @version 3.25.1\n */\n\n let version = source.match(/@version\\s+([\\d\\.]+)/);\n if (!version || !version[1]) {\n throw new Error(\n `Could not find version string in \\`${templateCompilerPath}\\`. Maybe we don't support your ember-source version?`\n );\n }\n\n let numbers = version[1].split('.');\n let major = parseInt(numbers[0], 10);\n let minor = parseInt(numbers[1], 10);\n let patch = parseInt(numbers[2], 10);\n\n return { major, minor, patch };\n}\n\nfunction emberVersionGte(templateCompilerPath: string, source: string, major: number, minor: number): boolean {\n let actual = parseVersion(templateCompilerPath, source);\n\n return actual.major > major || (actual.major === major && actual.minor >= minor);\n}\n\nexport function patch(source: string, templateCompilerPath: string): string {\n let version = parseVersion(templateCompilerPath, source);\n\n if (\n emberVersionGte(templateCompilerPath, source, 3, 26) ||\n (version.major === 3 && version.minor === 25 && version.patch >= 2) ||\n (version.major === 3 && version.minor === 24 && version.patch >= 3)\n ) {\n // no modifications are needed after\n // https://github.com/emberjs/ember.js/pull/19426 and backported to\n // 3.26.0-beta.3, 3.25.2, 3.24.3\n return source;\n }\n\n let replacedVar = false;\n let patchedSource;\n\n let needsAngleBracketPrinterFix =\n emberVersionGte(templateCompilerPath, source, 3, 12) && !emberVersionGte(templateCompilerPath, source, 3, 17);\n\n if (needsAngleBracketPrinterFix) {\n // here we are stripping off the first `var Ember;`. That one small change\n // lets us crack open the file and get access to its internal loader, because\n // we can give it our own predefined `Ember` variable instead, which it will\n // use and put `Ember.__loader` onto.\n //\n // on ember 3.12 through 3.16 (which use variants of glimmer-vm 0.38.5) we\n // also apply a patch to the printer in @glimmer/syntax to fix\n // https://github.com/glimmerjs/glimmer-vm/pull/941/files because it can\n // really bork apps under embroider, and we'd like to support at least all\n // active LTS versions of ember.\n patchedSource = transform(source, {\n plugins: [\n function () {\n return {\n visitor: {\n VariableDeclarator(path: NodePath<t.VariableDeclarator>) {\n let id = path.node.id;\n if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {\n replacedVar = true;\n path.remove();\n }\n },\n CallExpression: {\n enter(path: NodePath<t.CallExpression>, state: BabelState) {\n let callee = path.get('callee');\n if (!callee.isIdentifier() || callee.node.name !== 'define') {\n return;\n }\n let firstArg = path.get('arguments')[0];\n if (!firstArg.isStringLiteral() || firstArg.node.value !== '@glimmer/syntax') {\n return;\n }\n state.definingGlimmerSyntax = path;\n },\n exit(path: NodePath<t.CallExpression>, state: BabelState) {\n if (state.definingGlimmerSyntax === path) {\n state.definingGlimmerSyntax = false;\n }\n },\n },\n FunctionDeclaration: {\n enter(path: NodePath<t.FunctionDeclaration>, state: BabelState) {\n if (!state.definingGlimmerSyntax) {\n return;\n }\n let id = path.get('id');\n if (id.isIdentifier() && id.node.name === 'build') {\n state.declaringBuildFunction = path;\n }\n },\n exit(path: NodePath<t.FunctionDeclaration>, state: BabelState) {\n if (state.declaringBuildFunction === path) {\n state.declaringBuildFunction = false;\n }\n },\n },\n SwitchCase: {\n enter(path: NodePath<t.SwitchCase>, state: BabelState) {\n if (!state.definingGlimmerSyntax) {\n return;\n }\n let test = path.get('test');\n if (test.isStringLiteral() && test.node.value === 'ElementNode') {\n state.caseElementNode = path;\n }\n },\n exit(path: NodePath<t.SwitchCase>, state: BabelState) {\n if (state.caseElementNode === path) {\n state.caseElementNode = false;\n }\n },\n },\n IfStatement(path: NodePath<t.IfStatement>, state: BabelState) {\n if (!state.caseElementNode) {\n return;\n }\n let test = path.get('test');\n // the place we want is the only if with a computed member\n // expression predicate.\n if (test.isMemberExpression() && test.node.computed) {\n path.node.alternate = t.ifStatement(\n t.memberExpression(t.identifier('ast'), t.identifier('selfClosing')),\n t.blockStatement([\n t.expressionStatement(\n t.callExpression(t.memberExpression(t.identifier('output'), t.identifier('push')), [\n t.stringLiteral(' />'),\n ])\n ),\n ]),\n path.node.alternate\n );\n }\n },\n },\n };\n },\n ],\n })!.code!;\n } else {\n // applies to < 3.12 and >= 3.17\n //\n // here we are stripping off the first `var Ember;`. That one small change\n // lets us crack open the file and get access to its internal loader, because\n // we can give it our own predefined `Ember` variable instead, which it will\n // use and put `Ember.__loader` onto.\n patchedSource = transform(source, {\n generatorOpts: {\n compact: true,\n },\n plugins: [\n function () {\n return {\n visitor: {\n VariableDeclarator(path: NodePath<t.VariableDeclarator>) {\n let id = path.node.id;\n if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {\n replacedVar = true;\n path.remove();\n }\n },\n },\n };\n },\n ],\n })!.code!;\n }\n\n if (!replacedVar) {\n throw new Error(\n `didn't find expected source in ${templateCompilerPath}. Maybe we don't support your ember-source version?`\n );\n }\n\n return `\n let Ember = {};\n ${patchedSource};\n module.exports.Ember = Ember;\n `;\n}\n\ninterface BabelState {\n definingGlimmerSyntax: NodePath | false;\n declaringBuildFunction: NodePath | false;\n caseElementNode: NodePath | false;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rename-require-plugin.js","sourceRoot":"","sources":["rename-require-plugin.ts"],"names":[],"mappings":";;AAGA,SAAwB,kBAAkB;IACxC,OAAO;QACL,OAAO,EAAE;YACP,sBAAsB,CAAC,IAAwC;gBAC7D,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;oBACtC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;iBAC9B;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAVD,qCAUC","sourcesContent":["import type * as t from '@babel/types';\nimport type { NodePath } from '@babel/traverse';\n\nexport default function inlineHBSTransform(): unknown {\n return {\n visitor: {\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n if (path.node.local.name === 'require') {\n path.scope.rename('require');\n }\n },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"rename-require-plugin.js","sourceRoot":"","sources":["rename-require-plugin.ts"],"names":[],"mappings":";;AAGA,SAAwB,kBAAkB;IACxC,OAAO;QACL,OAAO,EAAE;YACP,sBAAsB,CAAC,IAAwC;gBAC7D,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;oBACtC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;iBAC9B;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAVD,qCAUC","sourcesContent":["import type { types as t } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\n\nexport default function inlineHBSTransform(): unknown {\n return {\n visitor: {\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n if (path.node.local.name === 'require') {\n path.scope.rename('require');\n }\n },\n },\n };\n}\n"]}
@@ -59,7 +59,9 @@ export declare class TemplateCompiler {
59
59
  get cacheKey(): string;
60
60
  private setup;
61
61
  private getReversedASTPlugins;
62
- precompile(moduleName: string, contents: string): {
62
+ precompile(templateSource: string, options: Record<string, unknown> & {
63
+ filename: string;
64
+ }): {
63
65
  compiled: string;
64
66
  dependencies: ResolvedDep[];
65
67
  };
@@ -51,31 +51,27 @@ class TemplateCompiler {
51
51
  return ast.slice().reverse();
52
52
  }
53
53
  // Compiles to the wire format plus dependency list.
54
- precompile(moduleName, contents) {
54
+ precompile(templateSource, options) {
55
55
  var _a, _b;
56
56
  let dependencies;
57
57
  let runtimeName;
58
+ let filename = options.filename;
58
59
  if (this.resolver) {
59
- runtimeName = this.resolver.absPathToRuntimePath(moduleName);
60
+ runtimeName = this.resolver.absPathToRuntimePath(filename);
60
61
  }
61
62
  else {
62
- runtimeName = moduleName;
63
+ runtimeName = filename;
63
64
  }
64
- let opts = this.syntax.defaultOptions({ contents, moduleName });
65
+ let opts = this.syntax.defaultOptions({ contents: templateSource, moduleName: filename });
65
66
  let plugins = Object.assign(Object.assign({}, opts === null || opts === void 0 ? void 0 : opts.plugins), { ast: [
66
67
  ...this.getReversedASTPlugins(this.plugins.ast),
67
68
  this.resolver && this.resolver.astTransformer(this),
68
69
  // Ember 3.27+ uses _buildCompileOptions will not add AST plugins to its result
69
70
  ...((_b = (_a = opts === null || opts === void 0 ? void 0 : opts.plugins) === null || _a === void 0 ? void 0 : _a.ast) !== null && _b !== void 0 ? _b : []),
70
71
  ].filter(Boolean) });
71
- let compiled = this.syntax.precompile((0, strip_bom_1.default)(contents), {
72
- contents,
73
- moduleName: runtimeName,
74
- filename: moduleName,
75
- plugins,
76
- });
72
+ let compiled = this.syntax.precompile((0, strip_bom_1.default)(templateSource), Object.assign({ contents: templateSource, moduleName: runtimeName, plugins }, options));
77
73
  if (this.resolver) {
78
- dependencies = this.resolver.dependenciesOf(moduleName);
74
+ dependencies = this.resolver.dependenciesOf(filename);
79
75
  }
80
76
  else {
81
77
  dependencies = [];
@@ -84,7 +80,7 @@ class TemplateCompiler {
84
80
  }
85
81
  // Compiles all the way from a template string to a javascript module string.
86
82
  compile(moduleName, contents) {
87
- let { compiled, dependencies } = this.precompile(moduleName, contents);
83
+ let { compiled, dependencies } = this.precompile(contents, { filename: moduleName });
88
84
  let lines = [];
89
85
  let counter = 0;
90
86
  for (let { runtimeName, path } of dependencies) {