@embroider/core 2.1.0 → 2.1.1-unstable.21eae41
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 +3 -4
- package/src/app-files.d.ts +1 -1
- package/src/app-files.js.map +1 -1
- package/src/app.d.ts +9 -7
- package/src/app.js +20 -31
- package/src/app.js.map +1 -1
- package/src/index.d.ts +3 -0
- package/src/index.js +5 -1
- package/src/index.js.map +1 -1
- package/src/module-resolver.d.ts +60 -22
- package/src/module-resolver.js +465 -136
- package/src/module-resolver.js.map +1 -1
- package/src/virtual-content.d.ts +3 -0
- package/src/virtual-content.js +87 -0
- package/src/virtual-content.js.map +1 -0
- package/src/wait-for-trees.js.map +1 -1
- package/src/babel-plugin-adjust-imports.d.ts +0 -31
- package/src/babel-plugin-adjust-imports.js +0 -224
- package/src/babel-plugin-adjust-imports.js.map +0 -1
- package/src/babel-plugin-inline-hbs-deps-node.d.ts +0 -14
- package/src/babel-plugin-inline-hbs-deps-node.js +0 -27
- package/src/babel-plugin-inline-hbs-deps-node.js.map +0 -1
- package/src/babel-plugin-inline-hbs-deps.d.ts +0 -10
- package/src/babel-plugin-inline-hbs-deps.js +0 -134
- package/src/babel-plugin-inline-hbs-deps.js.map +0 -1
- package/src/babel-plugin-inline-hbs-node.d.ts +0 -7
- package/src/babel-plugin-inline-hbs-node.js +0 -15
- package/src/babel-plugin-inline-hbs-node.js.map +0 -1
- package/src/babel-plugin-inline-hbs.d.ts +0 -24
- package/src/babel-plugin-inline-hbs.js +0 -142
- package/src/babel-plugin-inline-hbs.js.map +0 -1
- package/src/babel-plugin-stage1-inline-hbs-node.d.ts +0 -12
- package/src/babel-plugin-stage1-inline-hbs-node.js +0 -9
- package/src/babel-plugin-stage1-inline-hbs-node.js.map +0 -1
- package/src/babel-plugin-stage1-inline-hbs.d.ts +0 -9
- package/src/babel-plugin-stage1-inline-hbs.js +0 -96
- package/src/babel-plugin-stage1-inline-hbs.js.map +0 -1
- package/src/browser-index.d.ts +0 -1
- package/src/browser-index.js +0 -6
- package/src/browser-index.js.map +0 -1
- package/src/ember-template-compiler-types.d.ts +0 -41
- package/src/ember-template-compiler-types.js +0 -3
- package/src/ember-template-compiler-types.js.map +0 -1
- package/src/load-ember-template-compiler.d.ts +0 -6
- package/src/load-ember-template-compiler.js +0 -57
- package/src/load-ember-template-compiler.js.map +0 -1
- package/src/mini-modules-polyfill.d.ts +0 -12
- package/src/mini-modules-polyfill.js +0 -80
- package/src/mini-modules-polyfill.js.map +0 -1
- package/src/patch-template-compiler.d.ts +0 -1
- package/src/patch-template-compiler.js +0 -176
- package/src/patch-template-compiler.js.map +0 -1
- package/src/resolver-plugin.d.ts +0 -3
- package/src/resolver-plugin.js +0 -53
- package/src/resolver-plugin.js.map +0 -1
- package/src/resolver.d.ts +0 -14
- package/src/resolver.js +0 -3
- package/src/resolver.js.map +0 -1
- package/src/template-compiler-common.d.ts +0 -70
- package/src/template-compiler-common.js +0 -176
- package/src/template-compiler-common.js.map +0 -1
- package/src/template-compiler-node.d.ts +0 -17
- package/src/template-compiler-node.js +0 -32
- package/src/template-compiler-node.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ember-template-compiler-types.js","sourceRoot":"","sources":["ember-template-compiler-types.ts"],"names":[],"mappings":"","sourcesContent":["export interface Plugins {\n ast?: unknown[];\n}\n\nexport interface AST {\n _deliberatelyOpaque: 'AST';\n}\n\nexport interface PreprocessOptions {\n contents: string;\n moduleName: string;\n plugins?: Plugins;\n filename?: string;\n\n parseOptions?: {\n srcName?: string;\n ignoreStandalone?: boolean;\n };\n\n // added in Ember 3.17 (@glimmer/syntax@0.40.2)\n mode?: 'codemod' | 'precompile';\n\n // added in Ember 3.25\n strictMode?: boolean;\n locals?: string[];\n}\n\nexport interface PrinterOptions {\n entityEncoding?: 'transformed' | 'raw';\n}\n\n// This just reflects the API we're extracting from ember-template-compiler.js,\n// plus a cache key that lets us know when the underlying source has remained\n// stable.\nexport interface GlimmerSyntax {\n preprocess(html: string, options?: PreprocessOptions): AST;\n print(ast: AST, options?: PrinterOptions): string;\n defaultOptions(options: PreprocessOptions): PreprocessOptions;\n precompile(\n templateContents: string,\n options: {\n contents: string;\n moduleName: string;\n filename: string;\n plugins?: any;\n parseOptions?: {\n srcName?: string;\n };\n }\n ): string;\n _Ember: { FEATURES: any; ENV: any };\n cacheKey: string;\n}\n"]}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEmberExports = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const vm_1 = require("vm");
|
|
6
|
-
const crypto_1 = require("crypto");
|
|
7
|
-
const patch_template_compiler_1 = require("./patch-template-compiler");
|
|
8
|
-
const CACHE = new Map();
|
|
9
|
-
function getEmberExports(templateCompilerPath) {
|
|
10
|
-
let entry = CACHE.get(templateCompilerPath);
|
|
11
|
-
if (entry) {
|
|
12
|
-
let currentStat = (0, fs_1.statSync)(templateCompilerPath);
|
|
13
|
-
// Let's ensure the template is still what we cached
|
|
14
|
-
if (currentStat.mode === entry.stat.mode &&
|
|
15
|
-
currentStat.size === entry.stat.size &&
|
|
16
|
-
currentStat.mtime.getTime() === entry.stat.mtime.getTime()) {
|
|
17
|
-
return entry.value;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
let stat = (0, fs_1.statSync)(templateCompilerPath);
|
|
21
|
-
let source = (0, patch_template_compiler_1.patch)((0, fs_1.readFileSync)(templateCompilerPath, 'utf8'), templateCompilerPath);
|
|
22
|
-
let theExports = undefined;
|
|
23
|
-
// cacheKey, theExports
|
|
24
|
-
let cacheKey = (0, crypto_1.createHash)('md5').update(source).digest('hex');
|
|
25
|
-
entry = Object.freeze({
|
|
26
|
-
value: {
|
|
27
|
-
cacheKey,
|
|
28
|
-
get theExports() {
|
|
29
|
-
if (theExports) {
|
|
30
|
-
return theExports;
|
|
31
|
-
}
|
|
32
|
-
// matches (essentially) what ember-cli-htmlbars does in https://git.io/Jtbpj
|
|
33
|
-
let sandbox = {
|
|
34
|
-
module: { require, exports: {} },
|
|
35
|
-
require,
|
|
36
|
-
};
|
|
37
|
-
if (typeof globalThis === 'undefined') {
|
|
38
|
-
// for Node 10 usage with Ember 3.27+ we have to define the `global` global
|
|
39
|
-
// in order for ember-template-compiler.js to evaluate properly
|
|
40
|
-
// due to this code https://git.io/Jtb7
|
|
41
|
-
sandbox.global = sandbox;
|
|
42
|
-
}
|
|
43
|
-
// using vm.createContext / vm.Script to ensure we evaluate in a fresh sandbox context
|
|
44
|
-
// so that any global mutation done within ember-template-compiler.js does not leak out
|
|
45
|
-
let context = (0, vm_1.createContext)(sandbox);
|
|
46
|
-
let script = new vm_1.Script(source, { filename: templateCompilerPath });
|
|
47
|
-
script.runInContext(context);
|
|
48
|
-
return (theExports = context.module.exports);
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
stat, // This is stored, so we can reload the templateCompiler if it changes mid-build.
|
|
52
|
-
});
|
|
53
|
-
CACHE.set(templateCompilerPath, entry);
|
|
54
|
-
return entry.value;
|
|
55
|
-
}
|
|
56
|
-
exports.getEmberExports = getEmberExports;
|
|
57
|
-
//# sourceMappingURL=load-ember-template-compiler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"load-ember-template-compiler.js","sourceRoot":"","sources":["load-ember-template-compiler.ts"],"names":[],"mappings":";;;AAAA,2BAAgD;AAChD,2BAA2C;AAC3C,mCAAoC;AACpC,uEAAkD;AAYlD,MAAM,KAAK,GAAG,IAAI,GAAG,EAAsC,CAAC;AAE5D,SAAgB,eAAe,CAAC,oBAA4B;IAC1D,IAAI,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAE5C,IAAI,KAAK,EAAE;QACT,IAAI,WAAW,GAAG,IAAA,aAAQ,EAAC,oBAAoB,CAAC,CAAC;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AAoB,EAAE,CAAC,CAAC;gBAEpE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;gBAC7B,OAAO,CAAC,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC/C,CAAC;SACF;QACD,IAAI,EAAE,iFAAiF;KACxF,CAAC,CAAC;IAEH,KAAK,CAAC,GAAG,CAAC,oBAAoB,EAAE,KAAK,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC,KAAK,CAAC;AACrB,CAAC;AA1DD,0CA0DC","sourcesContent":["import fs, { readFileSync, statSync } from 'fs';\nimport { createContext, Script } from 'vm';\nimport { createHash } from 'crypto';\nimport { patch } from './patch-template-compiler';\n\ntype TemplateCompilerCacheEntry = {\n value: EmbersExports;\n stat: fs.Stats;\n};\n\ntype EmbersExports = {\n cacheKey: string;\n theExports: any;\n};\n\nconst CACHE = new Map<string, TemplateCompilerCacheEntry>();\n\nexport function getEmberExports(templateCompilerPath: string): EmbersExports {\n let entry = CACHE.get(templateCompilerPath);\n\n if (entry) {\n let currentStat = statSync(templateCompilerPath);\n\n // Let's ensure the template is still what we cached\n if (\n currentStat.mode === entry.stat.mode &&\n currentStat.size === entry.stat.size &&\n currentStat.mtime.getTime() === entry.stat.mtime.getTime()\n ) {\n return entry.value;\n }\n }\n\n let stat = statSync(templateCompilerPath);\n\n let source = patch(readFileSync(templateCompilerPath, 'utf8'), templateCompilerPath);\n let theExports: any = undefined;\n\n // cacheKey, theExports\n let cacheKey = createHash('md5').update(source).digest('hex');\n\n entry = Object.freeze({\n value: {\n cacheKey,\n get theExports() {\n if (theExports) {\n return theExports;\n }\n\n // matches (essentially) what ember-cli-htmlbars does in https://git.io/Jtbpj\n let sandbox = {\n module: { require, exports: {} },\n require,\n };\n\n if (typeof globalThis === 'undefined') {\n // for Node 10 usage with Ember 3.27+ we have to define the `global` global\n // in order for ember-template-compiler.js to evaluate properly\n // due to this code https://git.io/Jtb7\n (sandbox as any).global = sandbox;\n }\n // using vm.createContext / vm.Script to ensure we evaluate in a fresh sandbox context\n // so that any global mutation done within ember-template-compiler.js does not leak out\n let context = createContext(sandbox);\n let script = new Script(source, { filename: templateCompilerPath });\n\n script.runInContext(context);\n return (theExports = context.module.exports);\n },\n },\n stat, // This is stored, so we can reload the templateCompiler if it changes mid-build.\n });\n\n CACHE.set(templateCompilerPath, entry);\n return entry.value;\n}\n"]}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { types as t } from '@babel/core';
|
|
2
|
-
import type { NodePath } from '@babel/traverse';
|
|
3
|
-
declare type BabelTypes = typeof t;
|
|
4
|
-
export default function miniModulesPolyfill(babel: unknown): {
|
|
5
|
-
visitor: {
|
|
6
|
-
Program: {
|
|
7
|
-
exit(path: NodePath<t.Program>): void;
|
|
8
|
-
};
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export declare function handleImportDeclaration(t: BabelTypes, path: NodePath<t.ImportDeclaration>): undefined;
|
|
12
|
-
export {};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.handleImportDeclaration = void 0;
|
|
4
|
-
// this is intentionally not the whole babel-plugin-ember-modules-api-polyfill.
|
|
5
|
-
// That runs very early, so any usage of polyfilled imports that gets emitted by
|
|
6
|
-
// our other babel plugins can't take advantage of it.
|
|
7
|
-
//
|
|
8
|
-
// If I was going to try to do this properly, I would change
|
|
9
|
-
// babel-plugin-ember-modules-api-polyfill to run very late in the game, like
|
|
10
|
-
// this code does, so that other plugins could always not worry about it. But
|
|
11
|
-
// seeing as modules-api-polyfill is already on the way out, it's simpler to
|
|
12
|
-
// just handle the small piece of its functionality that matter to us:
|
|
13
|
-
//
|
|
14
|
-
// - all our usage (emitted by our babel plugins) is static imports, not dynamic
|
|
15
|
-
// ones, so it's OK to just walk the top level, saving us the cost of a full
|
|
16
|
-
// traverse
|
|
17
|
-
// - we only emit a handful of specific imports that are easy to just list here
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
let replacements = {
|
|
21
|
-
'@ember/component/template-only': {
|
|
22
|
-
default(t) {
|
|
23
|
-
return t.memberExpression(t.identifier('Ember'), t.identifier('_templateOnlyComponent'));
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
'@ember/template-factory': {
|
|
27
|
-
createTemplateFactory(t) {
|
|
28
|
-
return t.memberExpression(t.memberExpression(t.identifier('Ember'), t.identifier('HTMLBars')), t.identifier('template'));
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
'@ember/component': {
|
|
32
|
-
default(t) {
|
|
33
|
-
return t.memberExpression(t.identifier('Ember'), t.identifier('Component'));
|
|
34
|
-
},
|
|
35
|
-
setComponentTemplate(t) {
|
|
36
|
-
return t.memberExpression(t.identifier('Ember'), t.identifier('_setComponentTemplate'));
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
function miniModulesPolyfill(babel) {
|
|
41
|
-
let t = babel.types;
|
|
42
|
-
return {
|
|
43
|
-
visitor: {
|
|
44
|
-
Program: {
|
|
45
|
-
exit(path) {
|
|
46
|
-
for (let child of path.get('body')) {
|
|
47
|
-
if (child.isImportDeclaration()) {
|
|
48
|
-
let replacement = handleImportDeclaration(t, child);
|
|
49
|
-
if (replacement) {
|
|
50
|
-
path.replaceWith(replacement);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
exports.default = miniModulesPolyfill;
|
|
60
|
-
function handleImportDeclaration(t, path) {
|
|
61
|
-
let match = replacements[path.node.source.value];
|
|
62
|
-
if (match) {
|
|
63
|
-
let specifiers = path.get('specifiers');
|
|
64
|
-
let replacers = specifiers.map(specifier => ({ replacer: match[specifier.node.local.name], specifier }));
|
|
65
|
-
if (replacers.every(r => Boolean(r.replacer))) {
|
|
66
|
-
path.replaceWith(t.variableDeclaration('const', replacers.map(r => t.variableDeclarator(r.specifier.node.local, r.replacer(t)))));
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
for (let { specifier, replacer } of replacers) {
|
|
70
|
-
if (replacer) {
|
|
71
|
-
path.insertAfter(t.variableDeclaration('const', [t.variableDeclarator(specifier.node.local, replacer(t))]));
|
|
72
|
-
specifier.remove();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
exports.handleImportDeclaration = handleImportDeclaration;
|
|
80
|
-
//# sourceMappingURL=mini-modules-polyfill.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,OAAO,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EACnE,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CACzB,CAAC;QAC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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"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function patch(source: string, templateCompilerPath: string): string;
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.patch = void 0;
|
|
4
|
-
const core_1 = require("@babel/core");
|
|
5
|
-
function parseVersion(templateCompilerPath, source) {
|
|
6
|
-
// ember-template-compiler.js contains a comment that indicates what version it is for
|
|
7
|
-
// that looks like:
|
|
8
|
-
/*!
|
|
9
|
-
* @overview Ember - JavaScript Application Framework
|
|
10
|
-
* @copyright Copyright 2011-2020 Tilde Inc. and contributors
|
|
11
|
-
* Portions Copyright 2006-2011 Strobe Inc.
|
|
12
|
-
* Portions Copyright 2008-2011 Apple Inc. All rights reserved.
|
|
13
|
-
* @license Licensed under MIT license
|
|
14
|
-
* See https://raw.github.com/emberjs/ember.js/master/LICENSE
|
|
15
|
-
* @version 3.25.1
|
|
16
|
-
*/
|
|
17
|
-
let version = source.match(/@version\s+([\d\.]+)/);
|
|
18
|
-
if (!version || !version[1]) {
|
|
19
|
-
throw new Error(`Could not find version string in \`${templateCompilerPath}\`. Maybe we don't support your ember-source version?`);
|
|
20
|
-
}
|
|
21
|
-
let numbers = version[1].split('.');
|
|
22
|
-
let major = parseInt(numbers[0], 10);
|
|
23
|
-
let minor = parseInt(numbers[1], 10);
|
|
24
|
-
let patch = parseInt(numbers[2], 10);
|
|
25
|
-
return { major, minor, patch };
|
|
26
|
-
}
|
|
27
|
-
function emberVersionGte(templateCompilerPath, source, major, minor) {
|
|
28
|
-
let actual = parseVersion(templateCompilerPath, source);
|
|
29
|
-
return actual.major > major || (actual.major === major && actual.minor >= minor);
|
|
30
|
-
}
|
|
31
|
-
function patch(source, templateCompilerPath) {
|
|
32
|
-
let version = parseVersion(templateCompilerPath, source);
|
|
33
|
-
if (emberVersionGte(templateCompilerPath, source, 3, 26) ||
|
|
34
|
-
(version.major === 3 && version.minor === 25 && version.patch >= 2) ||
|
|
35
|
-
(version.major === 3 && version.minor === 24 && version.patch >= 3)) {
|
|
36
|
-
// no modifications are needed after
|
|
37
|
-
// https://github.com/emberjs/ember.js/pull/19426 and backported to
|
|
38
|
-
// 3.26.0-beta.3, 3.25.2, 3.24.3
|
|
39
|
-
return source;
|
|
40
|
-
}
|
|
41
|
-
let replacedVar = false;
|
|
42
|
-
let patchedSource;
|
|
43
|
-
let needsAngleBracketPrinterFix = emberVersionGte(templateCompilerPath, source, 3, 12) && !emberVersionGte(templateCompilerPath, source, 3, 17);
|
|
44
|
-
if (needsAngleBracketPrinterFix) {
|
|
45
|
-
// here we are stripping off the first `var Ember;`. That one small change
|
|
46
|
-
// lets us crack open the file and get access to its internal loader, because
|
|
47
|
-
// we can give it our own predefined `Ember` variable instead, which it will
|
|
48
|
-
// use and put `Ember.__loader` onto.
|
|
49
|
-
//
|
|
50
|
-
// on ember 3.12 through 3.16 (which use variants of glimmer-vm 0.38.5) we
|
|
51
|
-
// also apply a patch to the printer in @glimmer/syntax to fix
|
|
52
|
-
// https://github.com/glimmerjs/glimmer-vm/pull/941/files because it can
|
|
53
|
-
// really bork apps under embroider, and we'd like to support at least all
|
|
54
|
-
// active LTS versions of ember.
|
|
55
|
-
patchedSource = (0, core_1.transform)(source, {
|
|
56
|
-
plugins: [
|
|
57
|
-
function () {
|
|
58
|
-
return {
|
|
59
|
-
visitor: {
|
|
60
|
-
VariableDeclarator(path) {
|
|
61
|
-
let id = path.node.id;
|
|
62
|
-
if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {
|
|
63
|
-
replacedVar = true;
|
|
64
|
-
path.remove();
|
|
65
|
-
}
|
|
66
|
-
},
|
|
67
|
-
CallExpression: {
|
|
68
|
-
enter(path, state) {
|
|
69
|
-
let callee = path.get('callee');
|
|
70
|
-
if (!callee.isIdentifier() || callee.node.name !== 'define') {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
let firstArg = path.get('arguments')[0];
|
|
74
|
-
if (!firstArg.isStringLiteral() || firstArg.node.value !== '@glimmer/syntax') {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
state.definingGlimmerSyntax = path;
|
|
78
|
-
},
|
|
79
|
-
exit(path, state) {
|
|
80
|
-
if (state.definingGlimmerSyntax === path) {
|
|
81
|
-
state.definingGlimmerSyntax = false;
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
FunctionDeclaration: {
|
|
86
|
-
enter(path, state) {
|
|
87
|
-
if (!state.definingGlimmerSyntax) {
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
let id = path.get('id');
|
|
91
|
-
if (id.isIdentifier() && id.node.name === 'build') {
|
|
92
|
-
state.declaringBuildFunction = path;
|
|
93
|
-
}
|
|
94
|
-
},
|
|
95
|
-
exit(path, state) {
|
|
96
|
-
if (state.declaringBuildFunction === path) {
|
|
97
|
-
state.declaringBuildFunction = false;
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
SwitchCase: {
|
|
102
|
-
enter(path, state) {
|
|
103
|
-
if (!state.definingGlimmerSyntax) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
let test = path.get('test');
|
|
107
|
-
if (test.isStringLiteral() && test.node.value === 'ElementNode') {
|
|
108
|
-
state.caseElementNode = path;
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
exit(path, state) {
|
|
112
|
-
if (state.caseElementNode === path) {
|
|
113
|
-
state.caseElementNode = false;
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
IfStatement(path, state) {
|
|
118
|
-
if (!state.caseElementNode) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
let test = path.get('test');
|
|
122
|
-
// the place we want is the only if with a computed member
|
|
123
|
-
// expression predicate.
|
|
124
|
-
if (test.isMemberExpression() && test.node.computed) {
|
|
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(' />'),
|
|
128
|
-
])),
|
|
129
|
-
]), path.node.alternate);
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
};
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
}).code;
|
|
137
|
-
}
|
|
138
|
-
else {
|
|
139
|
-
// applies to < 3.12 and >= 3.17
|
|
140
|
-
//
|
|
141
|
-
// here we are stripping off the first `var Ember;`. That one small change
|
|
142
|
-
// lets us crack open the file and get access to its internal loader, because
|
|
143
|
-
// we can give it our own predefined `Ember` variable instead, which it will
|
|
144
|
-
// use and put `Ember.__loader` onto.
|
|
145
|
-
patchedSource = (0, core_1.transform)(source, {
|
|
146
|
-
generatorOpts: {
|
|
147
|
-
compact: true,
|
|
148
|
-
},
|
|
149
|
-
plugins: [
|
|
150
|
-
function () {
|
|
151
|
-
return {
|
|
152
|
-
visitor: {
|
|
153
|
-
VariableDeclarator(path) {
|
|
154
|
-
let id = path.node.id;
|
|
155
|
-
if (id.type === 'Identifier' && id.name === 'Ember' && !replacedVar) {
|
|
156
|
-
replacedVar = true;
|
|
157
|
-
path.remove();
|
|
158
|
-
}
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
|
-
],
|
|
164
|
-
}).code;
|
|
165
|
-
}
|
|
166
|
-
if (!replacedVar) {
|
|
167
|
-
throw new Error(`didn't find expected source in ${templateCompilerPath}. Maybe we don't support your ember-source version?`);
|
|
168
|
-
}
|
|
169
|
-
return `
|
|
170
|
-
let Ember = {};
|
|
171
|
-
${patchedSource};
|
|
172
|
-
module.exports.Ember = Ember;
|
|
173
|
-
`;
|
|
174
|
-
}
|
|
175
|
-
exports.patch = patch;
|
|
176
|
-
//# sourceMappingURL=patch-template-compiler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"patch-template-compiler.js","sourceRoot":"","sources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E;QACF,0EAA0E;QAC1E,6EAA6E;QAC7E,4EAA4E;QAC5E,qCAAqC;QACrC,aAAa,GAAG,IAAA,gBAAS,EAAC,MAAM,EAAE;YAChC,aAAa,EAAE;gBACb,OAAO,EAAE,IAAI;aACd;YACD,OAAO,EAAE;gBACP;oBACE,OAAO;wBACL,OAAO,EAAE;4BACP,kBAAkB,CAAC,IAAoC;gCACrD,IAAI,EAAE,GAAG,IAAI,CAAC,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"]}
|
package/src/resolver-plugin.d.ts
DELETED
package/src/resolver-plugin.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
exports.resolverPlugin = void 0;
|
|
7
|
-
const unplugin_1 = require("unplugin");
|
|
8
|
-
const module_resolver_1 = require("./module-resolver");
|
|
9
|
-
const assert_never_1 = __importDefault(require("assert-never"));
|
|
10
|
-
exports.resolverPlugin = (0, unplugin_1.createUnplugin)((resolverOptions) => {
|
|
11
|
-
return {
|
|
12
|
-
name: 'unplugin-embroider-resolver',
|
|
13
|
-
async resolveId(id, importer, _options) {
|
|
14
|
-
if (!importer) {
|
|
15
|
-
return null;
|
|
16
|
-
}
|
|
17
|
-
let resolution = resolverFor(importer, resolverOptions).resolve(id);
|
|
18
|
-
switch (resolution.result) {
|
|
19
|
-
case 'external':
|
|
20
|
-
// according to the docs we should be allowed to return `{ external:
|
|
21
|
-
// true, id: resolution.specifier }` here and that would take care of
|
|
22
|
-
// externalizing. But due to https://github.com/unjs/unplugin/issues/238
|
|
23
|
-
// that doesn't work, so we will generate our own runtime stubs via the
|
|
24
|
-
// load hook below.
|
|
25
|
-
return `@embroider/externals/${resolution.specifier}`;
|
|
26
|
-
case 'continue':
|
|
27
|
-
// null is the "defer to other plugins and default resolution" outcome
|
|
28
|
-
return null;
|
|
29
|
-
case 'redirect-to':
|
|
30
|
-
return null;
|
|
31
|
-
default:
|
|
32
|
-
throw (0, assert_never_1.default)(resolution);
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
async load(id) {
|
|
36
|
-
if (id.startsWith('@embroider/externals/')) {
|
|
37
|
-
let moduleName = id.slice('@embroider/externals/'.length);
|
|
38
|
-
return (0, module_resolver_1.externalShim)({ moduleName });
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
});
|
|
43
|
-
let prev;
|
|
44
|
-
function resolverFor(importer, resolverOptions) {
|
|
45
|
-
// as a very simple cache, reuse the same Resolver if we're still working
|
|
46
|
-
// from the same importer as the last call. We'd expect that is a common
|
|
47
|
-
// case, and we can avoid re-discovering things like the owning package of
|
|
48
|
-
// the importer.
|
|
49
|
-
let resolver = (prev === null || prev === void 0 ? void 0 : prev.importer) === importer ? prev.resolver : new module_resolver_1.Resolver(importer, resolverOptions);
|
|
50
|
-
prev = { importer, resolver };
|
|
51
|
-
return resolver;
|
|
52
|
-
}
|
|
53
|
-
//# sourceMappingURL=resolver-plugin.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver-plugin.js","sourceRoot":"","sources":["resolver-plugin.ts"],"names":[],"mappings":";;;;;;AAAA,uCAA0C;AAC1C,uDAA6F;AAC7F,gEAAuC;AAI1B,QAAA,cAAc,GAAG,IAAA,yBAAc,EAAC,CAAC,eAAsC,EAAE,EAAE;IACtF,OAAO;QACL,IAAI,EAAE,6BAA6B;QACnC,KAAK,CAAC,SAAS,CACb,EAAU,EACV,QAA4B,EAC5B,QAEC;YAED,IAAI,CAAC,QAAQ,EAAE;gBACb,OAAO,IAAI,CAAC;aACb;YAED,IAAI,UAAU,GAAG,WAAW,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAEpE,QAAQ,UAAU,CAAC,MAAM,EAAE;gBACzB,KAAK,UAAU;oBACb,oEAAoE;oBACpE,qEAAqE;oBACrE,wEAAwE;oBACxE,uEAAuE;oBACvE,mBAAmB;oBACnB,OAAO,wBAAwB,UAAU,CAAC,SAAS,EAAE,CAAC;gBACxD,KAAK,UAAU;oBACb,sEAAsE;oBACtE,OAAO,IAAI,CAAC;gBACd,KAAK,aAAa;oBAChB,OAAO,IAAI,CAAC;gBACd;oBACE,MAAM,IAAA,sBAAW,EAAC,UAAU,CAAC,CAAC;aACjC;QACH,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,EAAU;YACnB,IAAI,EAAE,CAAC,UAAU,CAAC,uBAAuB,CAAC,EAAE;gBAC1C,IAAI,UAAU,GAAG,EAAE,CAAC,KAAK,CAAC,uBAAuB,CAAC,MAAM,CAAC,CAAC;gBAC1D,OAAO,IAAA,8BAAY,EAAC,EAAE,UAAU,EAAE,CAAC,CAAC;aACrC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,IAAI,IAKS,CAAC;AAEd,SAAS,WAAW,CAAC,QAAgB,EAAE,eAAsC;IAC3E,yEAAyE;IACzE,wEAAwE;IACxE,0EAA0E;IAC1E,gBAAgB;IAChB,IAAI,QAAQ,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,QAAQ,MAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,0BAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IACrG,IAAI,GAAG,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC;IAC9B,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { createUnplugin } from 'unplugin';\nimport { externalShim, Options as ResolverPluginOptions, Resolver } from './module-resolver';\nimport assertNever from 'assert-never';\n\nexport { ResolverPluginOptions };\n\nexport const resolverPlugin = createUnplugin((resolverOptions: ResolverPluginOptions) => {\n return {\n name: 'unplugin-embroider-resolver',\n async resolveId(\n id: string,\n importer: string | undefined,\n _options: {\n isEntry: boolean;\n }\n ) {\n if (!importer) {\n return null;\n }\n\n let resolution = resolverFor(importer, resolverOptions).resolve(id);\n\n switch (resolution.result) {\n case 'external':\n // according to the docs we should be allowed to return `{ external:\n // true, id: resolution.specifier }` here and that would take care of\n // externalizing. But due to https://github.com/unjs/unplugin/issues/238\n // that doesn't work, so we will generate our own runtime stubs via the\n // load hook below.\n return `@embroider/externals/${resolution.specifier}`;\n case 'continue':\n // null is the \"defer to other plugins and default resolution\" outcome\n return null;\n case 'redirect-to':\n return null;\n default:\n throw assertNever(resolution);\n }\n },\n async load(id: string) {\n if (id.startsWith('@embroider/externals/')) {\n let moduleName = id.slice('@embroider/externals/'.length);\n return externalShim({ moduleName });\n }\n },\n };\n});\n\nlet prev:\n | {\n importer: string;\n resolver: Resolver;\n }\n | undefined;\n\nfunction resolverFor(importer: string, resolverOptions: ResolverPluginOptions): Resolver {\n // as a very simple cache, reuse the same Resolver if we're still working\n // from the same importer as the last call. We'd expect that is a common\n // case, and we can avoid re-discovering things like the owning package of\n // the importer.\n let resolver = prev?.importer === importer ? prev.resolver : new Resolver(importer, resolverOptions);\n prev = { importer, resolver };\n return resolver;\n}\n"]}
|
package/src/resolver.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { TemplateCompiler } from './template-compiler-common';
|
|
2
|
-
import { Options } from './babel-plugin-adjust-imports';
|
|
3
|
-
export interface ResolvedDep {
|
|
4
|
-
runtimeName: string;
|
|
5
|
-
path: string;
|
|
6
|
-
absPath: string;
|
|
7
|
-
}
|
|
8
|
-
export interface Resolver {
|
|
9
|
-
astTransformer(templateCompiler: TemplateCompiler): unknown;
|
|
10
|
-
dependenciesOf(moduleName: string): ResolvedDep[];
|
|
11
|
-
absPathToRuntimePath(absPath: string): string;
|
|
12
|
-
absPathToRuntimeName(absPath: string): string;
|
|
13
|
-
adjustImportsOptions: Options;
|
|
14
|
-
}
|
package/src/resolver.js
DELETED
package/src/resolver.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.js","sourceRoot":"","sources":["resolver.ts"],"names":[],"mappings":"","sourcesContent":["import type { TemplateCompiler } from './template-compiler-common';\nimport { Options } from './babel-plugin-adjust-imports';\n\nexport interface ResolvedDep {\n runtimeName: string;\n path: string;\n absPath: string;\n}\n\nexport interface Resolver {\n astTransformer(templateCompiler: TemplateCompiler): unknown;\n dependenciesOf(moduleName: string): ResolvedDep[];\n\n // this takes an absolute path to a file and gives back a path like\n // \"the-package-name/path/to/the-file.js\", while taking into account any\n // backward-compatible runtime name of the package. It's used by the template\n // compiler, because this is the kind of path AST plugins expect to see.\n absPathToRuntimePath(absPath: string): string;\n\n // this takes an absolute path to a file and gives back the runtime name of\n // that module, as it would tradtionally be named within loader.js.\n absPathToRuntimeName(absPath: string): string;\n\n adjustImportsOptions: Options;\n}\n"]}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { Resolver, ResolvedDep } from './resolver';
|
|
2
|
-
export interface Plugins {
|
|
3
|
-
ast?: unknown[];
|
|
4
|
-
}
|
|
5
|
-
export interface AST {
|
|
6
|
-
_deliberatelyOpaque: 'AST';
|
|
7
|
-
}
|
|
8
|
-
export interface PreprocessOptions {
|
|
9
|
-
contents: string;
|
|
10
|
-
moduleName: string;
|
|
11
|
-
plugins?: Plugins;
|
|
12
|
-
filename?: string;
|
|
13
|
-
parseOptions?: {
|
|
14
|
-
srcName?: string;
|
|
15
|
-
ignoreStandalone?: boolean;
|
|
16
|
-
};
|
|
17
|
-
mode?: 'codemod' | 'precompile';
|
|
18
|
-
strictMode?: boolean;
|
|
19
|
-
locals?: string[];
|
|
20
|
-
}
|
|
21
|
-
export interface PrinterOptions {
|
|
22
|
-
entityEncoding?: 'transformed' | 'raw';
|
|
23
|
-
}
|
|
24
|
-
export interface GlimmerSyntax {
|
|
25
|
-
preprocess(html: string, options?: PreprocessOptions): AST;
|
|
26
|
-
print(ast: AST, options?: PrinterOptions): string;
|
|
27
|
-
defaultOptions(options: PreprocessOptions): PreprocessOptions;
|
|
28
|
-
precompile(templateContents: string, options: {
|
|
29
|
-
contents: string;
|
|
30
|
-
moduleName: string;
|
|
31
|
-
filename: string;
|
|
32
|
-
plugins?: any;
|
|
33
|
-
parseOptions?: {
|
|
34
|
-
srcName?: string;
|
|
35
|
-
};
|
|
36
|
-
}): string;
|
|
37
|
-
_Ember: {
|
|
38
|
-
FEATURES: any;
|
|
39
|
-
ENV: any;
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export interface TemplateCompilerParams {
|
|
43
|
-
loadEmberTemplateCompiler: () => {
|
|
44
|
-
theExports: unknown;
|
|
45
|
-
cacheKey: string;
|
|
46
|
-
};
|
|
47
|
-
resolver?: Resolver;
|
|
48
|
-
EmberENV: unknown;
|
|
49
|
-
plugins: Plugins;
|
|
50
|
-
}
|
|
51
|
-
export declare class TemplateCompiler {
|
|
52
|
-
private loadEmberTemplateCompiler;
|
|
53
|
-
private resolver?;
|
|
54
|
-
private EmberENV;
|
|
55
|
-
private plugins;
|
|
56
|
-
constructor(params: TemplateCompilerParams);
|
|
57
|
-
private get syntax();
|
|
58
|
-
get cacheKey(): string;
|
|
59
|
-
private setup;
|
|
60
|
-
private getReversedASTPlugins;
|
|
61
|
-
precompile(templateSource: string, options: Record<string, unknown> & {
|
|
62
|
-
filename: string;
|
|
63
|
-
}): {
|
|
64
|
-
compiled: string;
|
|
65
|
-
dependencies: ResolvedDep[];
|
|
66
|
-
};
|
|
67
|
-
applyTransforms(moduleName: string, contents: string): string;
|
|
68
|
-
parse(moduleName: string, contents: string): AST;
|
|
69
|
-
baseDir(): string;
|
|
70
|
-
}
|