@embroider/core 3.4.20-unstable.b89b741 → 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 +9 -19
- 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 +3 -3
- package/src/index.js +3 -3
- 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 +60 -17
- package/src/module-resolver.js +307 -432
- package/src/module-resolver.js.map +1 -1
- package/src/options.d.ts +7 -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/to-broccoli-plugin.d.ts +8 -0
- package/src/to-broccoli-plugin.js +30 -0
- package/src/to-broccoli-plugin.js.map +1 -0
- package/src/virtual-content.d.ts +4 -6
- package/src/virtual-content.js +99 -67
- package/src/virtual-content.js.map +1 -1
- package/src/module-request.d.ts +0 -45
- package/src/module-request.js +0 -91
- package/src/module-request.js.map +0 -1
- package/src/module-resolver-options.d.ts +0 -42
- package/src/module-resolver-options.js +0 -164
- package/src/module-resolver-options.js.map +0 -1
- package/src/node-resolve.d.ts +0 -29
- package/src/node-resolve.js +0 -114
- 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 -94
- 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 -57
- 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","sourceRoot":"","sources":["portable-babel-config.ts"],"names":[],"mappings":";;;;;AAQA,oCAMC;AAbD,+BAA4B;AAC5B,sDAA8B;AAE9B,yCAAsC;AAItC,SAAgB,YAAY,CAC1B,MAAwB,EACxB,cAA8B,EAC9B,KAAqB;IAErB,OAAO,IAAI,mBAAmB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,mBAAmB;IAIvB,YAAY,cAA8B,EAAU,KAAqB;QAArB,UAAK,GAAL,KAAK,CAAgB;QACvE,IAAI,SAAS,IAAI,cAAc,EAAE,CAAC;YAChC,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,OAAO,GAAG,cAAc,CAAC,OAAO,CAAC;YACtC,IAAI,CAAC,OAAO,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,iBAAO,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC;QAC3F,CAAC;IACH,CAAC;IAED,OAAO,CAAC,MAAwB;QAC9B,IAAI,QAAQ,GAAa,IAAI,mBAAQ,CAAC;YACpC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,SAAS,EAAE,CAAC,KAAU,EAAE,UAAoB,EAAE,EAAE;gBAC9C,uEAAuE;gBACvE,kEAAkE;gBAClE,WAAW;gBACX,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,UAAU,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,EAAE,CAAC;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C,GAAG,CAAC,EAAE,CAAC;gBACjD,MAAM,GAAG,CAAC;YACZ,CAAC;YACD,IAAI,CAAC;gBACH,IAAI,QAAQ,CAAC;gBACb,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBACzB,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":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,CAAC;gBACb,KAAK,KAAK,CAAC;gBACX,KAAK,MAAM;oBACT,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;gBACzB,KAAK,SAAS;oBACZ,OAAO,IAAI,KAAK,CAAC,QAAQ,EAAE,YAAY,CAAC,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"]}
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import Plugin from 'broccoli-plugin';
|
2
|
+
import type { PackagerConstructor, Variant } from './packager';
|
3
|
+
import type Stage from './stage';
|
4
|
+
interface BroccoliPackager<Options> {
|
5
|
+
new (stage: Stage, variants: Variant[], options?: Options): Plugin;
|
6
|
+
}
|
7
|
+
export default function toBroccoliPlugin<Options>(packagerClass: PackagerConstructor<Options>): BroccoliPackager<Options>;
|
8
|
+
export {};
|
@@ -0,0 +1,30 @@
|
|
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.default = toBroccoliPlugin;
|
7
|
+
const broccoli_plugin_1 = __importDefault(require("broccoli-plugin"));
|
8
|
+
const shared_internals_1 = require("@embroider/shared-internals");
|
9
|
+
function toBroccoliPlugin(packagerClass) {
|
10
|
+
class PackagerRunner extends broccoli_plugin_1.default {
|
11
|
+
constructor(stage, variants, options) {
|
12
|
+
super([stage.tree], {
|
13
|
+
persistentOutput: true,
|
14
|
+
needsCache: false,
|
15
|
+
annotation: packagerClass.annotation,
|
16
|
+
});
|
17
|
+
this.stage = stage;
|
18
|
+
this.variants = variants;
|
19
|
+
this.options = options;
|
20
|
+
}
|
21
|
+
async build() {
|
22
|
+
if (!this.packager) {
|
23
|
+
this.packager = new packagerClass(this.stage.inputPath, this.outputPath, this.variants, msg => console.log(msg.split(shared_internals_1.tmpdir).join('$TMPDIR')), this.options);
|
24
|
+
}
|
25
|
+
return this.packager.build();
|
26
|
+
}
|
27
|
+
}
|
28
|
+
return PackagerRunner;
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=to-broccoli-plugin.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"to-broccoli-plugin.js","sourceRoot":"","sources":["to-broccoli-plugin.ts"],"names":[],"mappings":";;;;;AASA,mCA2BC;AApCD,sEAAqC;AAGrC,kEAAqD;AAMrD,SAAwB,gBAAgB,CACtC,aAA2C;IAE3C,MAAM,cAAe,SAAQ,yBAAM;QAEjC,YAAoB,KAAY,EAAU,QAAmB,EAAU,OAAiB;YACtF,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;gBAClB,gBAAgB,EAAE,IAAI;gBACtB,UAAU,EAAE,KAAK;gBACjB,UAAU,EAAE,aAAa,CAAC,UAAU;aACrC,CAAC,CAAC;YALe,UAAK,GAAL,KAAK,CAAO;YAAU,aAAQ,GAAR,QAAQ,CAAW;YAAU,YAAO,GAAP,OAAO,CAAU;QAMxF,CAAC;QAED,KAAK,CAAC,KAAK;YACT,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACnB,IAAI,CAAC,QAAQ,GAAG,IAAI,aAAa,CAC/B,IAAI,CAAC,KAAK,CAAC,SAAS,EACpB,IAAI,CAAC,UAAU,EACf,IAAI,CAAC,QAAQ,EACb,GAAG,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,yBAAM,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,EACrD,IAAI,CAAC,OAAO,CACb,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QAC/B,CAAC;KACF;IACD,OAAO,cAAc,CAAC;AACxB,CAAC","sourcesContent":["import Plugin from 'broccoli-plugin';\nimport type { Packager, PackagerConstructor, Variant } from './packager';\nimport type Stage from './stage';\nimport { tmpdir } from '@embroider/shared-internals';\n\ninterface BroccoliPackager<Options> {\n new (stage: Stage, variants: Variant[], options?: Options): Plugin;\n}\n\nexport default function toBroccoliPlugin<Options>(\n packagerClass: PackagerConstructor<Options>\n): BroccoliPackager<Options> {\n class PackagerRunner extends Plugin {\n private packager: Packager | undefined;\n constructor(private stage: Stage, private variants: Variant[], private options?: Options) {\n super([stage.tree], {\n persistentOutput: true,\n needsCache: false,\n annotation: packagerClass.annotation,\n });\n }\n\n async build() {\n if (!this.packager) {\n this.packager = new packagerClass(\n this.stage.inputPath,\n this.outputPath,\n this.variants,\n msg => console.log(msg.split(tmpdir).join('$TMPDIR')),\n this.options\n );\n }\n return this.packager.build();\n }\n }\n return PackagerRunner;\n}\n"]}
|
package/src/virtual-content.d.ts
CHANGED
@@ -1,10 +1,8 @@
|
|
1
1
|
import type { Resolver } from '.';
|
2
|
-
export
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
export declare function virtualContent(filename: string, resolver: Resolver): VirtualContentResult;
|
7
|
-
export declare function virtualPairComponent(hbsModule: string, jsModule: string | undefined): string;
|
2
|
+
export declare function virtualContent(filename: string, resolver: Resolver): string;
|
3
|
+
export declare function virtualExternalESModule(specifier: string, exports: string[] | undefined): string;
|
4
|
+
export declare function virtualExternalCJSModule(specifier: string): string;
|
5
|
+
export declare function virtualPairComponent(hbsModule: string, jsModule: string | null): string;
|
8
6
|
export declare function fastbootSwitch(specifier: string, fromFile: string, names: Set<string>): string;
|
9
7
|
export declare function decodeFastbootSwitch(filename: string): {
|
10
8
|
names: string[];
|
package/src/virtual-content.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.virtualContent = virtualContent;
|
4
|
+
exports.virtualExternalESModule = virtualExternalESModule;
|
5
|
+
exports.virtualExternalCJSModule = virtualExternalCJSModule;
|
4
6
|
exports.virtualPairComponent = virtualPairComponent;
|
5
7
|
exports.fastbootSwitch = fastbootSwitch;
|
6
8
|
exports.decodeFastbootSwitch = decodeFastbootSwitch;
|
@@ -8,24 +10,20 @@ exports.decodeImplicitModules = decodeImplicitModules;
|
|
8
10
|
const path_1 = require("path");
|
9
11
|
const _1 = require(".");
|
10
12
|
const js_handlebars_1 = require("./js-handlebars");
|
11
|
-
const
|
12
|
-
const
|
13
|
-
const virtual_vendor_1 = require("./virtual-vendor");
|
14
|
-
const virtual_vendor_styles_1 = require("./virtual-vendor-styles");
|
15
|
-
const virtual_entrypoint_1 = require("./virtual-entrypoint");
|
16
|
-
const virtual_route_entrypoint_1 = require("./virtual-route-entrypoint");
|
13
|
+
const externalESPrefix = '/@embroider/ext-es/';
|
14
|
+
const externalCJSPrefix = '/@embroider/ext-cjs/';
|
17
15
|
// Given a filename that was passed to your ModuleRequest's `virtualize()`,
|
18
16
|
// this produces the corresponding contents. It's a static, stateless function
|
19
17
|
// because we recognize that that process that did resolution might not be the
|
20
18
|
// same one that loads the content.
|
21
19
|
function virtualContent(filename, resolver) {
|
22
|
-
let
|
23
|
-
if (
|
24
|
-
return (
|
20
|
+
let cjsExtern = decodeVirtualExternalCJSModule(filename);
|
21
|
+
if (cjsExtern) {
|
22
|
+
return renderCJSExternalShim(cjsExtern);
|
25
23
|
}
|
26
|
-
let
|
27
|
-
if (
|
28
|
-
return (
|
24
|
+
let extern = decodeVirtualExternalESModule(filename);
|
25
|
+
if (extern) {
|
26
|
+
return renderESExternalShim(extern);
|
29
27
|
}
|
30
28
|
let match = decodeVirtualPairComponent(filename);
|
31
29
|
if (match) {
|
@@ -33,37 +31,39 @@ function virtualContent(filename, resolver) {
|
|
33
31
|
}
|
34
32
|
let fb = decodeFastbootSwitch(filename);
|
35
33
|
if (fb) {
|
36
|
-
return
|
34
|
+
return fastbootSwitchTemplate(fb);
|
37
35
|
}
|
38
36
|
let im = decodeImplicitModules(filename);
|
39
37
|
if (im) {
|
40
38
|
return renderImplicitModules(im, resolver);
|
41
39
|
}
|
42
|
-
let isVendor = (0, virtual_vendor_1.decodeVirtualVendor)(filename);
|
43
|
-
if (isVendor) {
|
44
|
-
return (0, virtual_vendor_1.renderVendor)(filename, resolver);
|
45
|
-
}
|
46
|
-
let isImplicitTestScripts = (0, virtual_test_support_1.decodeImplicitTestScripts)(filename);
|
47
|
-
if (isImplicitTestScripts) {
|
48
|
-
return (0, virtual_test_support_1.renderImplicitTestScripts)(filename, resolver);
|
49
|
-
}
|
50
|
-
let isVendorStyles = (0, virtual_vendor_styles_1.decodeVirtualVendorStyles)(filename);
|
51
|
-
if (isVendorStyles) {
|
52
|
-
return (0, virtual_vendor_styles_1.renderVendorStyles)(filename, resolver);
|
53
|
-
}
|
54
|
-
let isTestSupportStyles = (0, virtual_test_support_styles_1.decodeTestSupportStyles)(filename);
|
55
|
-
if (isTestSupportStyles) {
|
56
|
-
return (0, virtual_test_support_styles_1.renderTestSupportStyles)(filename, resolver);
|
57
|
-
}
|
58
40
|
throw new Error(`not an @embroider/core virtual file: ${filename}`);
|
59
41
|
}
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
42
|
+
const externalESShim = (0, js_handlebars_1.compile)(`
|
43
|
+
{{#if (eq moduleName "require")}}
|
44
|
+
const m = window.requirejs;
|
45
|
+
export default m;
|
46
|
+
const has = m.has;
|
47
|
+
export { has }
|
48
|
+
{{else}}
|
49
|
+
const m = window.require("{{{js-string-escape moduleName}}}");
|
50
|
+
{{#if default}}
|
51
|
+
export default m.default;
|
52
|
+
{{/if}}
|
53
|
+
{{#if names}}
|
54
|
+
const { {{#each names as |name|}}{{name}}, {{/each}} } = m;
|
55
|
+
export { {{#each names as |name|}}{{name}}, {{/each}} }
|
56
|
+
{{/if}}
|
57
|
+
{{/if}}
|
58
|
+
`);
|
59
|
+
function renderESExternalShim({ moduleName, exports }) {
|
60
|
+
return externalESShim({
|
61
|
+
moduleName,
|
62
|
+
default: exports.includes('default'),
|
63
|
+
names: exports.filter(n => n !== 'default'),
|
64
|
+
});
|
65
65
|
}
|
66
|
-
const
|
66
|
+
const pairedComponentShim = (0, js_handlebars_1.compile)(`
|
67
67
|
import { setComponentTemplate } from "@ember/component";
|
68
68
|
import template from "{{{js-string-escape relativeHBSModule}}}";
|
69
69
|
import { deprecate } from "@ember/debug";
|
@@ -90,14 +90,42 @@ import templateOnlyComponent from "@ember/component/template-only";
|
|
90
90
|
export default setComponentTemplate(template, templateOnlyComponent(undefined, "{{{js-string-escape debugName}}}"));
|
91
91
|
{{/if}}
|
92
92
|
`);
|
93
|
+
function virtualExternalESModule(specifier, exports) {
|
94
|
+
if (exports) {
|
95
|
+
return externalESPrefix + specifier + `?exports=${exports.join(',')}`;
|
96
|
+
}
|
97
|
+
else {
|
98
|
+
return externalESPrefix + specifier;
|
99
|
+
}
|
100
|
+
}
|
101
|
+
function virtualExternalCJSModule(specifier) {
|
102
|
+
return externalCJSPrefix + specifier;
|
103
|
+
}
|
104
|
+
function decodeVirtualExternalESModule(filename) {
|
105
|
+
if (filename.startsWith(externalESPrefix)) {
|
106
|
+
let exports = [];
|
107
|
+
let url = new URL(filename.slice(externalESPrefix.length), 'http://example.com');
|
108
|
+
let nameString = url.searchParams.get('exports');
|
109
|
+
if (nameString) {
|
110
|
+
exports = nameString.split(',');
|
111
|
+
}
|
112
|
+
let moduleName = url.pathname.slice(1);
|
113
|
+
return { moduleName, exports };
|
114
|
+
}
|
115
|
+
}
|
116
|
+
function decodeVirtualExternalCJSModule(filename) {
|
117
|
+
if (filename.startsWith(externalCJSPrefix)) {
|
118
|
+
return { moduleName: filename.slice(externalCJSPrefix.length) };
|
119
|
+
}
|
120
|
+
}
|
93
121
|
const pairComponentMarker = '-embroider-pair-component';
|
94
|
-
const pairComponentPattern = /^(?<hbsModule>.*)
|
122
|
+
const pairComponentPattern = /^(?<hbsModule>.*)\/(?<jsModule>[^\/]*)-embroider-pair-component$/;
|
95
123
|
function virtualPairComponent(hbsModule, jsModule) {
|
96
124
|
let relativeJSModule = '';
|
97
125
|
if (jsModule) {
|
98
|
-
relativeJSModule = (0, _1.explicitRelative)(
|
126
|
+
relativeJSModule = (0, _1.explicitRelative)(hbsModule, jsModule);
|
99
127
|
}
|
100
|
-
return `${hbsModule}
|
128
|
+
return `${hbsModule}/${encodeURIComponent(relativeJSModule)}${pairComponentMarker}`;
|
101
129
|
}
|
102
130
|
function decodeVirtualPairComponent(filename) {
|
103
131
|
// Performance: avoid paying regex exec cost unless needed
|
@@ -144,12 +172,6 @@ function decodeFastbootSwitch(filename) {
|
|
144
172
|
};
|
145
173
|
}
|
146
174
|
}
|
147
|
-
function renderFastbootSwitchTemplate(params) {
|
148
|
-
return {
|
149
|
-
src: fastbootSwitchTemplate(params),
|
150
|
-
watches: [],
|
151
|
-
};
|
152
|
-
}
|
153
175
|
const fastbootSwitchTemplate = (0, js_handlebars_1.compile)(`
|
154
176
|
import { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';
|
155
177
|
let mod;
|
@@ -185,8 +207,8 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
|
|
185
207
|
if (!(pkg === null || pkg === void 0 ? void 0 : pkg.isV2Ember())) {
|
186
208
|
throw new Error(`bug: saw special implicit modules import in non-ember package at ${fromFile}`);
|
187
209
|
}
|
188
|
-
let
|
189
|
-
let
|
210
|
+
let lazyModules = [];
|
211
|
+
let eagerModules = [];
|
190
212
|
let deps = pkg.dependencies.sort(orderAddons);
|
191
213
|
for (let dep of deps) {
|
192
214
|
// anything that isn't a v2 ember package by this point is not an active
|
@@ -219,7 +241,7 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
|
|
219
241
|
runtime = renamedModules[runtimeRenameLookup];
|
220
242
|
}
|
221
243
|
runtime = runtime.split(path_1.sep).join('/');
|
222
|
-
|
244
|
+
lazyModules.push({
|
223
245
|
runtime,
|
224
246
|
buildtime: path_1.posix.join(packageName, name),
|
225
247
|
});
|
@@ -228,32 +250,20 @@ function renderImplicitModules({ type, fromFile, }, resolver) {
|
|
228
250
|
// we don't recurse across an engine boundary. Engines import their own
|
229
251
|
// implicit-modules.
|
230
252
|
if (!dep.isEngine()) {
|
231
|
-
|
253
|
+
eagerModules.push(path_1.posix.join(dep.name, `-embroider-${type}.js`));
|
232
254
|
}
|
233
255
|
}
|
234
|
-
return
|
256
|
+
return implicitModulesTemplate({ lazyModules, eagerModules });
|
235
257
|
}
|
236
258
|
const implicitModulesTemplate = (0, js_handlebars_1.compile)(`
|
237
|
-
|
238
|
-
|
239
|
-
{{#each
|
240
|
-
|
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}}");});
|
241
263
|
{{/each}}
|
242
|
-
|
243
|
-
{{
|
244
|
-
import * as own{{index}} from "{{js-string-escape module.buildtime}}";
|
264
|
+
{{#each eagerModules as |module|}}
|
265
|
+
import "{{js-string-escape module}}";
|
245
266
|
{{/each}}
|
246
|
-
|
247
|
-
export default Object.assign({},
|
248
|
-
{{#each dependencyModules as |module index|}}
|
249
|
-
dep{{index}},
|
250
|
-
{{/each}}
|
251
|
-
{
|
252
|
-
{{#each ownModules as |module index|}}
|
253
|
-
"{{js-string-escape module.runtime}}": own{{index}},
|
254
|
-
{{/each}}
|
255
|
-
}
|
256
|
-
);
|
257
267
|
`);
|
258
268
|
// meta['renamed-modules'] has mapping from classic filename to real filename.
|
259
269
|
// This takes that and converts it to the inverst mapping from real import path
|
@@ -279,4 +289,26 @@ function orderAddons(depA, depB) {
|
|
279
289
|
}
|
280
290
|
return depAIdx - depBIdx;
|
281
291
|
}
|
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.
|
302
|
+
|
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.
|
306
|
+
|
307
|
+
todo: get review on this part.
|
308
|
+
-}}
|
309
|
+
if (m.default && !m.__esModule) {
|
310
|
+
m.__esModule = true;
|
311
|
+
}
|
312
|
+
module.exports = m;
|
313
|
+
`);
|
282
314
|
//# sourceMappingURL=virtual-content.js.map
|