@embroider/core 3.4.20-unstable.aaeb674 → 3.4.20
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 +8 -18
- package/src/app-files.d.ts +5 -3
- package/src/app-files.js +8 -25
- package/src/app-files.js.map +1 -1
- package/src/asset.d.ts +32 -0
- package/src/asset.js +3 -0
- package/src/asset.js.map +1 -0
- package/src/ember-html.d.ts +43 -0
- package/src/ember-html.js +110 -0
- package/src/ember-html.js.map +1 -0
- package/src/index.d.ts +2 -2
- package/src/index.js.map +1 -1
- package/src/measure-concat.js +2 -1
- package/src/measure-concat.js.map +1 -1
- package/src/module-resolver.d.ts +43 -28
- package/src/module-resolver.js +242 -440
- package/src/module-resolver.js.map +1 -1
- package/src/options.d.ts +4 -0
- package/src/options.js +1 -0
- package/src/options.js.map +1 -1
- package/src/portable-babel-config.d.ts +11 -0
- package/src/portable-babel-config.js +132 -0
- package/src/portable-babel-config.js.map +1 -0
- package/src/portable-babel-launcher.d.ts +6 -0
- package/src/portable-babel-launcher.js +75 -0
- package/src/portable-babel-launcher.js.map +1 -0
- package/src/resolver-loader.js +1 -8
- package/src/resolver-loader.js.map +1 -1
- package/src/virtual-content.d.ts +2 -6
- package/src/virtual-content.js +45 -117
- package/src/virtual-content.js.map +1 -1
- package/src/module-resolver-options.d.ts +0 -44
- package/src/module-resolver-options.js +0 -167
- package/src/module-resolver-options.js.map +0 -1
- package/src/node-resolve.d.ts +0 -33
- package/src/node-resolve.js +0 -131
- package/src/node-resolve.js.map +0 -1
- package/src/virtual-entrypoint.d.ts +0 -19
- package/src/virtual-entrypoint.js +0 -289
- package/src/virtual-entrypoint.js.map +0 -1
- package/src/virtual-route-entrypoint.d.ts +0 -15
- package/src/virtual-route-entrypoint.js +0 -101
- package/src/virtual-route-entrypoint.js.map +0 -1
- package/src/virtual-test-support-styles.d.ts +0 -4
- package/src/virtual-test-support-styles.js +0 -64
- package/src/virtual-test-support-styles.js.map +0 -1
- package/src/virtual-test-support.d.ts +0 -4
- package/src/virtual-test-support.js +0 -68
- package/src/virtual-test-support.js.map +0 -1
- package/src/virtual-vendor-styles.d.ts +0 -4
- package/src/virtual-vendor-styles.js +0 -82
- package/src/virtual-vendor-styles.js.map +0 -1
- package/src/virtual-vendor.d.ts +0 -4
- package/src/virtual-vendor.js +0 -72
- package/src/virtual-vendor.js.map +0 -1
- package/types/virtual/index.d.ts +0 -9
- package/types/virtual/index.js +0 -3
@@ -0,0 +1,132 @@
|
|
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.makePortable = makePortable;
|
7
|
+
const path_1 = require("path");
|
8
|
+
const resolve_1 = __importDefault(require("resolve"));
|
9
|
+
const portable_1 = require("./portable");
|
10
|
+
function makePortable(config, resolveOptions, hints) {
|
11
|
+
return new PortableBabelConfig(resolveOptions, hints).convert(config);
|
12
|
+
}
|
13
|
+
class PortableBabelConfig {
|
14
|
+
constructor(resolveOptions, hints) {
|
15
|
+
this.hints = hints;
|
16
|
+
if ('resolve' in resolveOptions) {
|
17
|
+
this.resolve = resolveOptions.resolve;
|
18
|
+
}
|
19
|
+
else {
|
20
|
+
this.basedir = resolveOptions.basedir;
|
21
|
+
this.resolve = (name) => resolve_1.default.sync(name, { basedir: resolveOptions.basedir });
|
22
|
+
}
|
23
|
+
}
|
24
|
+
convert(config) {
|
25
|
+
let portable = new portable_1.Portable({
|
26
|
+
hints: this.hints,
|
27
|
+
dehydrate: (value, accessPath) => {
|
28
|
+
// this custom dehydrate hook handles babel plugins & presets. If we're
|
29
|
+
// not looking at plugins or presets, continue with stock Portable
|
30
|
+
// behavior
|
31
|
+
if (accessPath.length !== 2 || (accessPath[0] !== 'plugins' && accessPath[0] !== 'presets')) {
|
32
|
+
return undefined;
|
33
|
+
}
|
34
|
+
// standardize to always handle an array
|
35
|
+
if (!Array.isArray(value)) {
|
36
|
+
value = [value];
|
37
|
+
}
|
38
|
+
let [plugin, argument, asName] = value;
|
39
|
+
// string plugins need to get resolved correctly into absolute paths,
|
40
|
+
// so they will really be portable
|
41
|
+
if (typeof plugin === 'string') {
|
42
|
+
plugin = this.resolveBabelPlugin(plugin);
|
43
|
+
}
|
44
|
+
// next we deal with serializability. Our Portable system already
|
45
|
+
// understands the protocol used by ember-cli-babel to identify plugin
|
46
|
+
// classes and get back to their serializable forms, so this will
|
47
|
+
// handle that case.
|
48
|
+
let dehydrated = portable.dehydrate([plugin, argument, asName], accessPath.concat('_internal'));
|
49
|
+
if (dehydrated.needsHydrate) {
|
50
|
+
// we can eliminate the need for rehydration by going through our own
|
51
|
+
// portable babel launcher
|
52
|
+
return {
|
53
|
+
value: [
|
54
|
+
(0, path_1.join)(__dirname, 'portable-babel-launcher.js'),
|
55
|
+
{ module: dehydrated.value[0], arg: dehydrated.value[1], hints: this.hints },
|
56
|
+
dehydrated.value[2] || `portable-babel-launcher-${accessPath[1]}`,
|
57
|
+
],
|
58
|
+
needsHydrate: false,
|
59
|
+
isParallelSafe: dehydrated.isParallelSafe,
|
60
|
+
};
|
61
|
+
}
|
62
|
+
else {
|
63
|
+
// trim back down our array, because trailing undefined will get
|
64
|
+
// converted into null via json.stringify, and babel will complain
|
65
|
+
// about that.
|
66
|
+
while (dehydrated.value.length > 0 && dehydrated.value[dehydrated.value.length - 1] == null) {
|
67
|
+
dehydrated.value.pop();
|
68
|
+
}
|
69
|
+
if (dehydrated.value.length === 1) {
|
70
|
+
dehydrated.value = dehydrated.value[0];
|
71
|
+
}
|
72
|
+
return {
|
73
|
+
value: dehydrated.value,
|
74
|
+
needsHydrate: dehydrated.needsHydrate,
|
75
|
+
isParallelSafe: dehydrated.isParallelSafe,
|
76
|
+
};
|
77
|
+
}
|
78
|
+
},
|
79
|
+
});
|
80
|
+
let result = portable.dehydrate(config);
|
81
|
+
if (result.needsHydrate) {
|
82
|
+
throw new Error(`bug: portable babel configs aren't supposed to need hydration`);
|
83
|
+
}
|
84
|
+
return { config: result.value, isParallelSafe: result.isParallelSafe };
|
85
|
+
}
|
86
|
+
// babel lets you use relative paths, absolute paths, package names, and
|
87
|
+
// package name shorthands.
|
88
|
+
//
|
89
|
+
// my-plugin -> my-plugin
|
90
|
+
// my-plugin -> babel-plugin-my-plugin
|
91
|
+
// @me/thing -> @me/thing
|
92
|
+
// @me/thing -> @me/babel-plugin-thing
|
93
|
+
// ./here -> /your/app/here
|
94
|
+
// /tmp/there -> /tmp/there
|
95
|
+
//
|
96
|
+
resolveBabelPlugin(name) {
|
97
|
+
try {
|
98
|
+
return this.resolve(name);
|
99
|
+
}
|
100
|
+
catch (err) {
|
101
|
+
if (err.code !== 'MODULE_NOT_FOUND') {
|
102
|
+
throw err;
|
103
|
+
}
|
104
|
+
if (name.startsWith('.') || name.startsWith('/')) {
|
105
|
+
throw err;
|
106
|
+
}
|
107
|
+
try {
|
108
|
+
let expanded;
|
109
|
+
if (name.startsWith('@')) {
|
110
|
+
let [space, pkg, ...rest] = name.split('/');
|
111
|
+
expanded = [space, `babel-plugin-${pkg}`, ...rest].join('/');
|
112
|
+
}
|
113
|
+
else {
|
114
|
+
expanded = `babel-plugin-${name}`;
|
115
|
+
}
|
116
|
+
return this.resolve(expanded);
|
117
|
+
}
|
118
|
+
catch (err2) {
|
119
|
+
if (err2.code !== 'MODULE_NOT_FOUND') {
|
120
|
+
throw err2;
|
121
|
+
}
|
122
|
+
if (this.basedir) {
|
123
|
+
throw new Error(`unable to resolve babel plugin ${name} from ${this.basedir}`);
|
124
|
+
}
|
125
|
+
else {
|
126
|
+
throw new Error(`unable to resolve babel plugin ${name}`);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}
|
132
|
+
//# sourceMappingURL=portable-babel-config.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"portable-babel-config.js","s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ACzB,IAAI,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;oBAC5C,QAAQ,GAAG,CAAC,KAAK,EAAE,gBAAgB,GAAG,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBAC/D,CAAC;qBAAM,CAAC;oBACN,QAAQ,GAAG,gBAAgB,IAAI,EAAE,CAAC;gBACpC,CAAC;gBACD,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAChC,CAAC;YAAC,OAAO,IAAI,EAAE,CAAC;gBACd,IAAI,IAAI,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;oBACrC,MAAM,IAAI,CAAC;gBACb,CAAC;gBACD,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACjB,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,SAAS,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;gBACjF,CAAC;qBAAM,CAAC;oBACN,MAAM,IAAI,KAAK,CAAC,kCAAkC,IAAI,EAAE,CAAC,CAAC;gBAC5D,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF","sourcesContent":["import type { TransformOptions } from '@babel/core';\nimport { join } from 'path';\nimport resolve from 'resolve';\nimport type { PortableHint } from './portable';\nimport { Portable } from './portable';\n\nexport type ResolveOptions = { basedir: string } | { resolve: (name: string) => any };\n\nexport function makePortable(\n config: TransformOptions,\n resolveOptions: ResolveOptions,\n hints: PortableHint[]\n): { config: TransformOptions; isParallelSafe: boolean } {\n return new PortableBabelConfig(resolveOptions, hints).convert(config);\n}\n\nclass PortableBabelConfig {\n private resolve: (name: string) => any;\n private basedir: string | undefined;\n\n constructor(resolveOptions: ResolveOptions, private hints: PortableHint[]) {\n if ('resolve' in resolveOptions) {\n this.resolve = resolveOptions.resolve;\n } else {\n this.basedir = resolveOptions.basedir;\n this.resolve = (name: string) => resolve.sync(name, { basedir: resolveOptions.basedir });\n }\n }\n\n convert(config: TransformOptions): { config: TransformOptions; isParallelSafe: boolean } {\n let portable: Portable = new Portable({\n hints: this.hints,\n dehydrate: (value: any, accessPath: string[]) => {\n // this custom dehydrate hook handles babel plugins & presets. If we're\n // not looking at plugins or presets, continue with stock Portable\n // behavior\n if (accessPath.length !== 2 || (accessPath[0] !== 'plugins' && accessPath[0] !== 'presets')) {\n return undefined;\n }\n\n // standardize to always handle an array\n if (!Array.isArray(value)) {\n value = [value];\n }\n\n let [plugin, argument, asName] = value;\n\n // string plugins need to get resolved correctly into absolute paths,\n // so they will really be portable\n if (typeof plugin === 'string') {\n plugin = this.resolveBabelPlugin(plugin);\n }\n\n // next we deal with serializability. Our Portable system already\n // understands the protocol used by ember-cli-babel to identify plugin\n // classes and get back to their serializable forms, so this will\n // handle that case.\n let dehydrated = portable.dehydrate([plugin, argument, asName], accessPath.concat('_internal'));\n\n if (dehydrated.needsHydrate) {\n // we can eliminate the need for rehydration by going through our own\n // portable babel launcher\n return {\n value: [\n join(__dirname, 'portable-babel-launcher.js'),\n { module: dehydrated.value[0], arg: dehydrated.value[1], hints: this.hints },\n dehydrated.value[2] || `portable-babel-launcher-${accessPath[1]}`,\n ],\n needsHydrate: false,\n isParallelSafe: dehydrated.isParallelSafe,\n };\n } else {\n // trim back down our array, because trailing undefined will get\n // converted into null via json.stringify, and babel will complain\n // about that.\n while (dehydrated.value.length > 0 && dehydrated.value[dehydrated.value.length - 1] == null) {\n dehydrated.value.pop();\n }\n if (dehydrated.value.length === 1) {\n dehydrated.value = dehydrated.value[0];\n }\n return {\n value: dehydrated.value,\n needsHydrate: dehydrated.needsHydrate,\n isParallelSafe: dehydrated.isParallelSafe,\n };\n }\n },\n });\n let result = portable.dehydrate(config);\n if (result.needsHydrate) {\n throw new Error(`bug: portable babel configs aren't supposed to need hydration`);\n }\n return { config: result.value, isParallelSafe: result.isParallelSafe };\n }\n\n // babel lets you use relative paths, absolute paths, package names, and\n // package name shorthands.\n //\n // my-plugin -> my-plugin\n // my-plugin -> babel-plugin-my-plugin\n // @me/thing -> @me/thing\n // @me/thing -> @me/babel-plugin-thing\n // ./here -> /your/app/here\n // /tmp/there -> /tmp/there\n //\n private resolveBabelPlugin(name: string) {\n try {\n return this.resolve(name);\n } catch (err) {\n if (err.code !== 'MODULE_NOT_FOUND') {\n throw err;\n }\n if (name.startsWith('.') || name.startsWith('/')) {\n throw err;\n }\n try {\n let expanded;\n if (name.startsWith('@')) {\n let [space, pkg, ...rest] = name.split('/');\n expanded = [space, `babel-plugin-${pkg}`, ...rest].join('/');\n } else {\n expanded = `babel-plugin-${name}`;\n }\n return this.resolve(expanded);\n } catch (err2) {\n if (err2.code !== 'MODULE_NOT_FOUND') {\n throw err2;\n }\n if (this.basedir) {\n throw new Error(`unable to resolve babel plugin ${name} from ${this.basedir}`);\n } else {\n throw new Error(`unable to resolve babel plugin ${name}`);\n }\n }\n }\n }\n}\n"]}
|
@@ -0,0 +1,75 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.default = babelLauncher;
|
4
|
+
const portable_1 = require("./portable");
|
5
|
+
function babelLauncher(babel, launch, key) {
|
6
|
+
let p = new portable_1.Portable({ hints: launch.hints });
|
7
|
+
let hydrated = p.hydrate(launch);
|
8
|
+
let module;
|
9
|
+
if (typeof hydrated.module === 'string') {
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
11
|
+
module = require(hydrated.module);
|
12
|
+
if (module.__esModule) {
|
13
|
+
module = module.default;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
else {
|
17
|
+
module = hydrated.module;
|
18
|
+
}
|
19
|
+
let plugin = module.call(this, babel, hydrated.arg, key);
|
20
|
+
let innerStates = new WeakMap();
|
21
|
+
function convertState(state) {
|
22
|
+
let innerState = innerStates.get(state);
|
23
|
+
if (!innerState) {
|
24
|
+
innerState = Object.assign({}, state, { opts: hydrated.arg });
|
25
|
+
innerStates.set(state, innerState);
|
26
|
+
}
|
27
|
+
return innerState;
|
28
|
+
}
|
29
|
+
function wrap1(original) {
|
30
|
+
if (typeof original === 'function') {
|
31
|
+
return function (file) {
|
32
|
+
return original.call(convertState(this), file);
|
33
|
+
};
|
34
|
+
}
|
35
|
+
}
|
36
|
+
function wrap2(original) {
|
37
|
+
return function (path, state) {
|
38
|
+
return original.call(convertState(this), path, convertState(state));
|
39
|
+
};
|
40
|
+
}
|
41
|
+
let visitorProxy = {
|
42
|
+
get(target, prop) {
|
43
|
+
let original = target[prop];
|
44
|
+
if (typeof original === 'function') {
|
45
|
+
return wrap2(original);
|
46
|
+
}
|
47
|
+
if (original && typeof original === 'object') {
|
48
|
+
let wrapped = {};
|
49
|
+
if (typeof original.exit === 'function') {
|
50
|
+
wrapped.exit = wrap2(original.exit);
|
51
|
+
}
|
52
|
+
if (typeof original.enter === 'function') {
|
53
|
+
wrapped.enter = wrap2(original.enter);
|
54
|
+
}
|
55
|
+
return wrapped;
|
56
|
+
}
|
57
|
+
return original;
|
58
|
+
},
|
59
|
+
};
|
60
|
+
return new Proxy(plugin, {
|
61
|
+
get(target, prop) {
|
62
|
+
let original = target[prop];
|
63
|
+
switch (prop) {
|
64
|
+
case 'pre':
|
65
|
+
case 'post':
|
66
|
+
return wrap1(original);
|
67
|
+
case 'visitor':
|
68
|
+
return new Proxy(original, visitorProxy);
|
69
|
+
default:
|
70
|
+
return original;
|
71
|
+
}
|
72
|
+
},
|
73
|
+
});
|
74
|
+
}
|
75
|
+
//# sourceMappingURL=portable-babel-launcher.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"portable-babel-launcher.js","sourceRoot":"","sources":["portable-babel-launcher.ts"],"names":[],"mappings":";;AAGA,gCA+EC;AAjFD,yCAAsC;AAEtC,SAAwB,aAAa,CAEnC,KAAU,EACV,MAAwD,EACxD,GAAW;IAEX,IAAI,CAAC,GAAG,IAAI,mBAAQ,CAAC,EAA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CAAC;gBAC3C;oBACE,OAAO,QAAQ,CAAC;YACpB,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { PortableHint } from './portable';\nimport { Portable } from './portable';\n\nexport default function babelLauncher(\n this: any,\n babel: any,\n launch: { module: any; arg: any; hints: PortableHint[] },\n key: string\n) {\n let p = new Portable({ hints: launch.hints });\n let hydrated = p.hydrate(launch);\n let module;\n if (typeof hydrated.module === 'string') {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n module = require(hydrated.module);\n if (module.__esModule) {\n module = module.default;\n }\n } else {\n module = hydrated.module;\n }\n\n let plugin = module.call(this, babel, hydrated.arg, key);\n let innerStates = new WeakMap();\n\n function convertState(state: any) {\n let innerState = innerStates.get(state);\n if (!innerState) {\n innerState = Object.assign({}, state, { opts: hydrated.arg });\n innerStates.set(state, innerState);\n }\n return innerState;\n }\n\n function wrap1(original: any) {\n if (typeof original === 'function') {\n return function (this: any, file: any) {\n return original.call(convertState(this), file);\n };\n }\n }\n\n function wrap2(original: Function) {\n return function (this: any, path: any, state: any) {\n return original.call(convertState(this), path, convertState(state));\n };\n }\n\n let visitorProxy = {\n get(target: any, prop: string) {\n let original = target[prop];\n if (typeof original === 'function') {\n return wrap2(original);\n }\n if (original && typeof original === 'object') {\n let wrapped: any = {};\n if (typeof original.exit === 'function') {\n wrapped.exit = wrap2(original.exit);\n }\n if (typeof original.enter === 'function') {\n wrapped.enter = wrap2(original.enter);\n }\n return wrapped;\n }\n return original;\n },\n };\n\n return new Proxy(plugin, {\n get(target, prop) {\n let original = target[prop];\n switch (prop) {\n case 'pre':\n case 'post':\n return wrap1(original);\n case 'visitor':\n return new Proxy(original, visitorProxy);\n default:\n return original;\n }\n },\n });\n}\n"]}
|
package/src/resolver-loader.js
CHANGED
@@ -14,7 +14,6 @@ var _ResolverLoader_resolver, _ResolverLoader_configFile, _ResolverLoader_watche
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
15
15
|
exports.ResolverLoader = void 0;
|
16
16
|
const fs_extra_1 = require("fs-extra");
|
17
|
-
const module_resolver_options_1 = require("./module-resolver-options");
|
18
17
|
const module_resolver_1 = require("./module-resolver");
|
19
18
|
const shared_internals_1 = require("@embroider/shared-internals");
|
20
19
|
const path_1 = require("path");
|
@@ -38,13 +37,7 @@ class ResolverLoader {
|
|
38
37
|
}
|
39
38
|
get resolver() {
|
40
39
|
if (!__classPrivateFieldGet(this, _ResolverLoader_resolver, "f")) {
|
41
|
-
let config;
|
42
|
-
if ((0, fs_extra_1.existsSync)(__classPrivateFieldGet(this, _ResolverLoader_configFile, "f"))) {
|
43
|
-
config = (0, fs_extra_1.readJSONSync)(__classPrivateFieldGet(this, _ResolverLoader_configFile, "f"));
|
44
|
-
}
|
45
|
-
else {
|
46
|
-
config = (0, module_resolver_options_1.buildResolverOptions)({});
|
47
|
-
}
|
40
|
+
let config = (0, fs_extra_1.readJSONSync)((0, path_1.join)((0, shared_internals_1.locateEmbroiderWorkingDir)(this.appRoot), 'resolver.json'));
|
48
41
|
__classPrivateFieldSet(this, _ResolverLoader_resolver, new module_resolver_1.Resolver(config), "f");
|
49
42
|
}
|
50
43
|
return __classPrivateFieldGet(this, _ResolverLoader_resolver, "f");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resolver-loader.js","sourceRoot":"","sources":["resolver-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
1
|
+
{"version":3,"file":"resolver-loader.js","sourceRoot":"","sources":["resolver-loader.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uCAAwC;AAExC,uDAA6C;AAC7C,kEAAwE;AACxE,+BAA4B;AAE5B,2BAAsC;AAEtC,MAAa,cAAc;IAKzB,YAAqB,OAAe,EAAE,KAAK,GAAG,KAAK;QAA9B,YAAO,GAAP,OAAO,CAAQ;QAJpC,2CAAgC;QAChC,6CAAoB;QACpB,0CAAgC;QAG9B,uBAAA,IAAI,8BAAe,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,MAAA,CAAC;QAClF,IAAI,KAAK,EAAE,CAAC;YACV,uBAAA,IAAI,2BAAY,IAAA,UAAO,EAAC,uBAAA,IAAI,kCAAY,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE,GAAG,EAAE;gBACpE,uBAAA,IAAI,4BAAa,SAAS,MAAA,CAAC;YAC7B,CAAC,CAAC,MAAA,CAAC;QACL,CAAC;IACH,CAAC;IAED,KAAK;;QACH,MAAA,uBAAA,IAAI,+BAAS,0CAAE,KAAK,EAAE,CAAC;IACzB,CAAC;IAED,IAAI,QAAQ;QACV,IAAI,CAAC,uBAAA,IAAI,gCAAU,EAAE,CAAC;YACpB,IAAI,MAAM,GAAY,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,IAAA,4CAAyB,EAAC,IAAI,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC;YACnG,uBAAA,IAAI,4BAAa,IAAI,0BAAQ,CAAC,MAAM,CAAC,MAAA,CAAC;QACxC,CAAC;QACD,OAAO,uBAAA,IAAI,gCAAU,CAAC;IACxB,CAAC;CACF;AAzBD,wCAyBC","sourcesContent":["import { readJSONSync } from 'fs-extra';\nimport type { Options } from './module-resolver';\nimport { Resolver } from './module-resolver';\nimport { locateEmbroiderWorkingDir } from '@embroider/shared-internals';\nimport { join } from 'path';\nimport type { FSWatcher } from 'fs';\nimport { watch as fsWatch } from 'fs';\n\nexport class ResolverLoader {\n #resolver: Resolver | undefined;\n #configFile: string;\n #watcher: FSWatcher | undefined;\n\n constructor(readonly appRoot: string, watch = false) {\n this.#configFile = join(locateEmbroiderWorkingDir(this.appRoot), 'resolver.json');\n if (watch) {\n this.#watcher = fsWatch(this.#configFile, { persistent: false }, () => {\n this.#resolver = undefined;\n });\n }\n }\n\n close() {\n this.#watcher?.close();\n }\n\n get resolver(): Resolver {\n if (!this.#resolver) {\n let config: Options = readJSONSync(join(locateEmbroiderWorkingDir(this.appRoot), 'resolver.json'));\n this.#resolver = new Resolver(config);\n }\n return this.#resolver;\n }\n}\n"]}
|
package/src/virtual-content.d.ts
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
import type { Resolver } from '.';
|
2
|
-
export
|
3
|
-
src: string;
|
4
|
-
watches: string[];
|
5
|
-
}
|
6
|
-
export declare function virtualContent(filename: string, resolver: Resolver): VirtualContentResult;
|
2
|
+
export declare function virtualContent(filename: string, resolver: Resolver): string;
|
7
3
|
export declare function virtualExternalESModule(specifier: string, exports: string[] | undefined): string;
|
8
4
|
export declare function virtualExternalCJSModule(specifier: string): string;
|
9
|
-
export declare function virtualPairComponent(hbsModule: string, jsModule: string |
|
5
|
+
export declare function virtualPairComponent(hbsModule: string, jsModule: string | null): string;
|
10
6
|
export declare function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string;
|
11
7
|
export declare function decodeFastbootSwitch(filename: string): {
|
12
8
|
names: string[];
|
package/src/virtual-content.js
CHANGED
@@ -10,12 +10,6 @@ exports.decodeImplicitModules = decodeImplicitModules;
|
|
10
10
|
const path_1 = require("path");
|
11
11
|
const _1 = require(".");
|
12
12
|
const js_handlebars_1 = require("./js-handlebars");
|
13
|
-
const virtual_test_support_1 = require("./virtual-test-support");
|
14
|
-
const virtual_test_support_styles_1 = require("./virtual-test-support-styles");
|
15
|
-
const virtual_vendor_1 = require("./virtual-vendor");
|
16
|
-
const virtual_vendor_styles_1 = require("./virtual-vendor-styles");
|
17
|
-
const virtual_entrypoint_1 = require("./virtual-entrypoint");
|
18
|
-
const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
|
19
13
|
const externalESPrefix = '/@embroider/ext-es/';
|
20
14
|
const externalCJSPrefix = '/@embroider/ext-cjs/';
|
21
15
|
// Given a filename that was passed to your ModuleRequest's `virtualize()`,
|
@@ -27,14 +21,6 @@ function virtualContent(filename, resolver) {
|
|
27
21
|
if (cjsExtern) {
|
28
22
|
return renderCJSExternalShim(cjsExtern);
|
29
23
|
}
|
30
|
-
let entrypoint = (0, virtual_entrypoint_1.decodeEntrypoint)(filename);
|
31
|
-
if (entrypoint) {
|
32
|
-
return (0, virtual_entrypoint_1.renderEntrypoint)(resolver, entrypoint);
|
33
|
-
}
|
34
|
-
let routeEntrypoint = (0, virtual_route_entrypoint_1.decodeRouteEntrypoint)(filename);
|
35
|
-
if (routeEntrypoint) {
|
36
|
-
return (0, virtual_route_entrypoint_1.renderRouteEntrypoint)(resolver, routeEntrypoint);
|
37
|
-
}
|
38
24
|
let extern = decodeVirtualExternalESModule(filename);
|
39
25
|
if (extern) {
|
40
26
|
return renderESExternalShim(extern);
|
@@ -45,28 +31,12 @@ function virtualContent(filename, resolver) {
|
|
45
31
|
}
|
46
32
|
let fb = decodeFastbootSwitch(filename);
|
47
33
|
if (fb) {
|
48
|
-
return
|
34
|
+
return fastbootSwitchTemplate(fb);
|
49
35
|
}
|
50
36
|
let im = decodeImplicitModules(filename);
|
51
37
|
if (im) {
|
52
38
|
return renderImplicitModules(im, resolver);
|
53
39
|
}
|
54
|
-
let isVendor = (0, virtual_vendor_1.decodeVirtualVendor)(filename);
|
55
|
-
if (isVendor) {
|
56
|
-
return (0, virtual_vendor_1.renderVendor)(filename, resolver);
|
57
|
-
}
|
58
|
-
let isImplicitTestScripts = (0, virtual_test_support_1.decodeImplicitTestScripts)(filename);
|
59
|
-
if (isImplicitTestScripts) {
|
60
|
-
return (0, virtual_test_support_1.renderImplicitTestScripts)(filename, resolver);
|
61
|
-
}
|
62
|
-
let isVendorStyles = (0, virtual_vendor_styles_1.decodeVirtualVendorStyles)(filename);
|
63
|
-
if (isVendorStyles) {
|
64
|
-
return (0, virtual_vendor_styles_1.renderVendorStyles)(filename, resolver);
|
65
|
-
}
|
66
|
-
let isTestSupportStyles = (0, virtual_test_support_styles_1.decodeTestSupportStyles)(filename);
|
67
|
-
if (isTestSupportStyles) {
|
68
|
-
return (0, virtual_test_support_styles_1.renderTestSupportStyles)(filename, resolver);
|
69
|
-
}
|
70
40
|
throw new Error(`not an @embroider/core virtual file: ${filename}`);
|
71
41
|
}
|
72
42
|
const externalESShim = (0, js_handlebars_1.compile)(`
|
@@ -86,23 +56,14 @@ export { {{#each names as |name|}}{{name}}, {{/each}} }
|
|
86
56
|
{{/if}}
|
87
57
|
{{/if}}
|
88
58
|
`);
|
89
|
-
function renderESExternalShim({ moduleName, exports
|
90
|
-
return {
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
}),
|
96
|
-
watches: [],
|
97
|
-
};
|
98
|
-
}
|
99
|
-
function pairedComponentShim(params) {
|
100
|
-
return {
|
101
|
-
src: pairedComponentShimTemplate(params),
|
102
|
-
watches: [],
|
103
|
-
};
|
59
|
+
function renderESExternalShim({ moduleName, exports }) {
|
60
|
+
return externalESShim({
|
61
|
+
moduleName,
|
62
|
+
default: exports.includes('default'),
|
63
|
+
names: exports.filter(n => n !== 'default'),
|
64
|
+
});
|
104
65
|
}
|
105
|
-
const
|
66
|
+
const pairedComponentShim = (0, js_handlebars_1.compile)(`
|
106
67
|
import { setComponentTemplate } from "@ember/component";
|
107
68
|
import template from "{{{js-string-escape relativeHBSModule}}}";
|
108
69
|
import { deprecate } from "@ember/debug";
|
@@ -131,7 +92,7 @@ export default setComponentTemplate(template, templateOnlyComponent(undefined, "
|
|
131
92
|
`);
|
132
93
|
function virtualExternalESModule(specifier, exports) {
|
133
94
|
if (exports) {
|
134
|
-
return externalESPrefix + specifier +
|
95
|
+
return externalESPrefix + specifier + `?exports=${exports.join(',')}`;
|
135
96
|
}
|
136
97
|
else {
|
137
98
|
return externalESPrefix + specifier;
|
@@ -143,12 +104,12 @@ function virtualExternalCJSModule(specifier) {
|
|
143
104
|
function decodeVirtualExternalESModule(filename) {
|
144
105
|
if (filename.startsWith(externalESPrefix)) {
|
145
106
|
let exports = [];
|
146
|
-
let
|
147
|
-
let nameString =
|
107
|
+
let url = new URL(filename.slice(externalESPrefix.length), 'http://example.com');
|
108
|
+
let nameString = url.searchParams.get('exports');
|
148
109
|
if (nameString) {
|
149
110
|
exports = nameString.split(',');
|
150
111
|
}
|
151
|
-
let moduleName =
|
112
|
+
let moduleName = url.pathname.slice(1);
|
152
113
|
return { moduleName, exports };
|
153
114
|
}
|
154
115
|
}
|
@@ -158,13 +119,13 @@ function decodeVirtualExternalCJSModule(filename) {
|
|
158
119
|
}
|
159
120
|
}
|
160
121
|
const pairComponentMarker = '-embroider-pair-component';
|
161
|
-
const pairComponentPattern = /^(?<hbsModule>.*)
|
122
|
+
const pairComponentPattern = /^(?<hbsModule>.*)\/(?<jsModule>[^\/]*)-embroider-pair-component$/;
|
162
123
|
function virtualPairComponent(hbsModule, jsModule) {
|
163
124
|
let relativeJSModule = '';
|
164
125
|
if (jsModule) {
|
165
|
-
relativeJSModule = (0, _1.explicitRelative)(
|
126
|
+
relativeJSModule = (0, _1.explicitRelative)(hbsModule, jsModule);
|
166
127
|
}
|
167
|
-
return `${hbsModule}
|
128
|
+
return `${hbsModule}/${encodeURIComponent(relativeJSModule)}${pairComponentMarker}`;
|
168
129
|
}
|
169
130
|
function decodeVirtualPairComponent(filename) {
|
170
131
|
// Performance: avoid paying regex exec cost unless needed
|
@@ -211,12 +172,6 @@ function decodeFastbootSwitch(filename) {
|
|
211
172
|
};
|
212
173
|
}
|
213
174
|
}
|
214
|
-
function renderFastbootSwitchTemplate(params) {
|
215
|
-
return {
|
216
|
-
src: fastbootSwitchTemplate(params),
|
217
|
-
watches: [],
|
218
|
-
};
|
219
|
-
}
|
220
175
|
const fastbootSwitchTemplate = (0, js_handlebars_1.compile)(`
|
221
176
|
import { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';
|
222
177
|
let mod;
|
@@ -252,8 +207,8 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
|
|
252
207
|
if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
|
253
208
|
throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);
|
254
209
|
}
|
255
|
-
let
|
256
|
-
let
|
210
|
+
let lazyModules = [];
|
211
|
+
let eagerModules = [];
|
257
212
|
let deps = pkg.dependencies.sort(orderAddons);
|
258
213
|
for (let dep of deps) {
|
259
214
|
// anything that isn't a v2 ember package by this point is not an active
|
@@ -286,7 +241,7 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
|
|
286
241
|
runtime = renamedModules[runtimeRenameLookup];
|
287
242
|
}
|
288
243
|
runtime = runtime.split(path_1.sep).join('/');
|
289
|
-
|
244
|
+
lazyModules.push({
|
290
245
|
runtime,
|
291
246
|
buildtime: path_1.posix.join(packageName, name),
|
292
247
|
});
|
@@ -295,32 +250,20 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
|
|
295
250
|
// we don't recurse across an engine boundary. Engines import their own
|
296
251
|
// implicit-modules.
|
297
252
|
if (!dep.isEngine()) {
|
298
|
-
|
253
|
+
eagerModules.push(path_1.posix.join(dep.name, `-embroider-${type}.js`));
|
299
254
|
}
|
300
255
|
}
|
301
|
-
return
|
256
|
+
return implicitModulesTemplate({ lazyModules, eagerModules });
|
302
257
|
}
|
303
258
|
const implicitModulesTemplate = (0, js_handlebars_1.compile)(`
|
304
|
-
|
305
|
-
|
306
|
-
{{#each
|
307
|
-
|
259
|
+
import { importSync as i } from '@embroider/macros';
|
260
|
+
let d = window.define;
|
261
|
+
{{#each lazyModules as |module|}}
|
262
|
+
d("{{js-string-escape module.runtime}}", function(){ return i("{{js-string-escape module.buildtime}}");});
|
308
263
|
{{/each}}
|
309
|
-
|
310
|
-
{{
|
311
|
-
import * as own{{index}} from "{{js-string-escape module.buildtime}}";
|
264
|
+
{{#each eagerModules as |module|}}
|
265
|
+
import "{{js-string-escape module}}";
|
312
266
|
{{/each}}
|
313
|
-
|
314
|
-
export default Object.assign({},
|
315
|
-
{{#each dependencyModules as |module index|}}
|
316
|
-
dep{{index}},
|
317
|
-
{{/each}}
|
318
|
-
{
|
319
|
-
{{#each ownModules as |module index|}}
|
320
|
-
"{{js-string-escape module.runtime}}": own{{index}},
|
321
|
-
{{/each}}
|
322
|
-
}
|
323
|
-
);
|
324
267
|
`);
|
325
268
|
// meta['renamed-modules'] has mapping from classic filename to real filename.
|
326
269
|
// This takes that and converts it to the inverst mapping from real import path
|
@@ -346,41 +289,26 @@ function orderAddons(depA, depB) {
|
|
346
289
|
}
|
347
290
|
return depAIdx - depBIdx;
|
348
291
|
}
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
}
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
{{!- our proxy always presents as ES module so that we can intercept "get('default')" -}}
|
360
|
-
if (prop === '__esModule') {
|
361
|
-
return true;
|
362
|
-
}
|
363
|
-
|
364
|
-
{{#if (eq moduleName "require")}}
|
365
|
-
const m = window.requirejs;
|
366
|
-
{{else}}
|
367
|
-
const m = window.require("{{{js-string-escape moduleName}}}");
|
368
|
-
{{/if}}
|
369
|
-
|
370
|
-
{{!-
|
371
|
-
There are plenty of hand-written AMD defines floating around
|
372
|
-
that lack an __esModule declaration.
|
292
|
+
const renderCJSExternalShim = (0, js_handlebars_1.compile)(`
|
293
|
+
{{#if (eq moduleName "require")}}
|
294
|
+
const m = window.requirejs;
|
295
|
+
{{else}}
|
296
|
+
const m = window.require("{{{js-string-escape moduleName}}}");
|
297
|
+
{{/if}}
|
298
|
+
{{!-
|
299
|
+
There are plenty of hand-written AMD defines floating around
|
300
|
+
that lack this, and they will break when other build systems
|
301
|
+
encounter them.
|
373
302
|
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
-}}
|
378
|
-
if (prop === 'default' && !m.__esModule && !m.default) {
|
379
|
-
return m;
|
380
|
-
}
|
303
|
+
As far as I can tell, Ember's loader was already treating this
|
304
|
+
case as a module, so in theory we aren't breaking anything by
|
305
|
+
marking it as such when other packagers come looking.
|
381
306
|
|
382
|
-
|
383
|
-
|
384
|
-
|
307
|
+
todo: get review on this part.
|
308
|
+
-}}
|
309
|
+
if (m.default && !m.__esModule) {
|
310
|
+
m.__esModule = true;
|
311
|
+
}
|
312
|
+
module.exports = m;
|
385
313
|
`);
|
386
314
|
//# sourceMappingURL=virtual-content.js.map
|