@embroider/core 3.4.10-unstable.3beedad → 3.4.10-unstable.6b85eb1
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 +6 -5
- package/src/app-files.d.ts +1 -1
- package/src/app-files.js +9 -2
- package/src/app-files.js.map +1 -1
- package/src/ember-html.js +1 -1
- package/src/ember-html.js.map +1 -1
- package/src/module-resolver.d.ts +6 -0
- package/src/module-resolver.js +65 -0
- package/src/module-resolver.js.map +1 -1
- package/src/virtual-content.js +15 -0
- package/src/virtual-content.js.map +1 -1
- package/src/virtual-entrypoint.d.ts +19 -0
- package/src/virtual-entrypoint.js +303 -0
- package/src/virtual-entrypoint.js.map +1 -0
- package/src/virtual-route-entrypoint.d.ts +15 -0
- package/src/virtual-route-entrypoint.js +102 -0
- package/src/virtual-route-entrypoint.js.map +1 -0
- package/src/virtual-test-entrypoint.d.ts +10 -0
- package/src/virtual-test-entrypoint.js +67 -0
- package/src/virtual-test-entrypoint.js.map +1 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.renderTestEntrypoint = exports.decodeTestEntrypoint = void 0;
|
4
|
+
const app_files_1 = require("./app-files");
|
5
|
+
const js_handlebars_1 = require("./js-handlebars");
|
6
|
+
const shared_internals_1 = require("@embroider/shared-internals");
|
7
|
+
const virtual_entrypoint_1 = require("./virtual-entrypoint");
|
8
|
+
const entrypointPattern = /(?<filename>.*)[\\/]-embroider-test-entrypoint.js/;
|
9
|
+
function decodeTestEntrypoint(filename) {
|
10
|
+
// Performance: avoid paying regex exec cost unless needed
|
11
|
+
if (!filename.includes('-embroider-test-entrypoint.js')) {
|
12
|
+
return;
|
13
|
+
}
|
14
|
+
let m = entrypointPattern.exec(filename);
|
15
|
+
if (m) {
|
16
|
+
return {
|
17
|
+
fromFile: m.groups.filename,
|
18
|
+
};
|
19
|
+
}
|
20
|
+
}
|
21
|
+
exports.decodeTestEntrypoint = decodeTestEntrypoint;
|
22
|
+
function renderTestEntrypoint(resolver, { fromFile }) {
|
23
|
+
const owner = resolver.packageCache.ownerOfFile(fromFile);
|
24
|
+
if (!owner) {
|
25
|
+
throw new Error(`Owner expected while loading test entrypoint from file: ${fromFile}`);
|
26
|
+
}
|
27
|
+
let engine = resolver.owningEngine(owner);
|
28
|
+
let appFiles = new app_files_1.AppFiles({
|
29
|
+
package: owner,
|
30
|
+
addons: new Map(engine.activeAddons.map(addon => [
|
31
|
+
resolver.packageCache.get(addon.root),
|
32
|
+
addon.canResolveFromFile,
|
33
|
+
])),
|
34
|
+
isApp: true,
|
35
|
+
modulePrefix: resolver.options.modulePrefix,
|
36
|
+
appRelativePath: 'NOT_USED_DELETE_ME',
|
37
|
+
}, (0, virtual_entrypoint_1.getAppFiles)(owner.root), new Set(), // no fastboot files
|
38
|
+
(0, shared_internals_1.extensionsPattern)(resolver.options.resolvableExtensions), (0, virtual_entrypoint_1.staticAppPathsPattern)(resolver.options.staticAppPaths), resolver.options.podModulePrefix);
|
39
|
+
let amdModules = [];
|
40
|
+
for (let relativePath of appFiles.tests) {
|
41
|
+
amdModules.push((0, virtual_entrypoint_1.importPaths)(resolver, appFiles, relativePath));
|
42
|
+
}
|
43
|
+
let src = entryTemplate({
|
44
|
+
amdModules,
|
45
|
+
});
|
46
|
+
return {
|
47
|
+
src,
|
48
|
+
watches: [],
|
49
|
+
};
|
50
|
+
}
|
51
|
+
exports.renderTestEntrypoint = renderTestEntrypoint;
|
52
|
+
const entryTemplate = (0, js_handlebars_1.compile)(`
|
53
|
+
import { importSync as i } from '@embroider/macros';
|
54
|
+
let w = window;
|
55
|
+
let d = w.define;
|
56
|
+
|
57
|
+
import "ember-testing";
|
58
|
+
import "@embroider/core/entrypoint";
|
59
|
+
|
60
|
+
{{#each amdModules as |amdModule| ~}}
|
61
|
+
d("{{js-string-escape amdModule.runtime}}", function(){ return i("{{js-string-escape amdModule.buildtime}}");});
|
62
|
+
{{/each}}
|
63
|
+
|
64
|
+
import('./tests/test-helper');
|
65
|
+
EmberENV.TESTS_FILE_LOADED = true;
|
66
|
+
`);
|
67
|
+
//# sourceMappingURL=virtual-test-entrypoint.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"virtual-test-entrypoint.js","sourceRoot":"","sources":["virtual-test-entrypoint.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AACvC,mDAA0C;AAE1C,kEAAgE;AAEhE,6DAAuF;AAEvF,MAAM,iBAAiB,GAAG,mDAAmD,CAAC;AAE9E,SAAgB,oBAAoB,CAAC,QAAgB;IACnD,0DAA0D;IAC1D,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,+BAA+B,CAAC,EAAE,CAAC;QACxD,OAAO;IACT,CAAC;IACD,IAAI,CAAC,GAAG,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACzC,IAAI,CAAC,EAAE,CAAC;QACN,OAAO;YACL,QAAQ,EAAE,CAAC,CAAC,MAAO,CAAC,QAAQ;SAC7B,CAAC;IACJ,CAAC;AACH,CAAC;AAXD,oDAWC;AAED,SAAgB,oBAAoB,CAClC,QAAkB,EAClB,EAAE,QAAQ,EAAwB;IAElC,MAAM,KAAK,GAAG,QAAQ,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,2DAA2D,QAAQ,EAAE,CAAC,CAAC;IACzF,CAAC;IAED,IAAI,MAAM,GAAG,QAAQ,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;IAE1C,IAAI,QAAQ,GAAG,IAAI,oBAAQ,CACzB;QACE,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,IAAI,GAAG,CACb,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAmB;YACvD,KAAK,CAAC,kBAAkB;SACzB,CAAC,CACH;QACD,KAAK,EAAE,IAAI;QACX,YAAY,EAAE,QAAQ,CAAC,OAAO,CAAC,YAAY;QAC3C,eAAe,EAAE,oBAAoB;KACtC,EACD,IAAA,gCAAW,EAAC,KAAK,CAAC,IAAI,CAAC,EACvB,IAAI,GAAG,EAAE,EAAE,oBAAoB;IAC/B,IAAA,oCAAiB,EAAC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAC,EACxD,IAAA,0CAAqB,EAAC,QAAQ,CAAC,OAAO,CAAC,cAAc,CAAC,EACtD,QAAQ,CAAC,OAAO,CAAC,eAAe,CACjC,CAAC;IAEF,IAAI,UAAU,GAA6C,EAAE,CAAC;IAE9D,KAAK,IAAI,YAAY,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;QACxC,UAAU,CAAC,IAAI,CAAC,IAAA,gCAAW,EAAC,QAAQ,EAAE,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,IAAI,GAAG,GAAG,aAAa,CAAC;QACtB,UAAU;KACX,CAAC,CAAC;IAEH,OAAO;QACL,GAAG;QACH,OAAO,EAAE,EAAE;KACZ,CAAC;AACJ,CAAC;AA9CD,oDA8CC;AAED,MAAM,aAAa,GAAG,IAAA,uBAAO,EAAC;;;;;;;;;;;;;;CAc7B,CAAiF,CAAC","sourcesContent":["import { AppFiles } from './app-files';\nimport { compile } from './js-handlebars';\nimport type { Resolver } from './module-resolver';\nimport { extensionsPattern } from '@embroider/shared-internals';\nimport type { V2AddonPackage } from '@embroider/shared-internals/src/package';\nimport { getAppFiles, importPaths, staticAppPathsPattern } from './virtual-entrypoint';\n\nconst entrypointPattern = /(?<filename>.*)[\\\\/]-embroider-test-entrypoint.js/;\n\nexport function decodeTestEntrypoint(filename: string): { fromFile: string } | undefined {\n // Performance: avoid paying regex exec cost unless needed\n if (!filename.includes('-embroider-test-entrypoint.js')) {\n return;\n }\n let m = entrypointPattern.exec(filename);\n if (m) {\n return {\n fromFile: m.groups!.filename,\n };\n }\n}\n\nexport function renderTestEntrypoint(\n resolver: Resolver,\n { fromFile }: { fromFile: string }\n): { src: string; watches: string[] } {\n const owner = resolver.packageCache.ownerOfFile(fromFile);\n\n if (!owner) {\n throw new Error(`Owner expected while loading test entrypoint from file: ${fromFile}`);\n }\n\n let engine = resolver.owningEngine(owner);\n\n let appFiles = new AppFiles(\n {\n package: owner,\n addons: new Map(\n engine.activeAddons.map(addon => [\n resolver.packageCache.get(addon.root) as V2AddonPackage,\n addon.canResolveFromFile,\n ])\n ),\n isApp: true,\n modulePrefix: resolver.options.modulePrefix,\n appRelativePath: 'NOT_USED_DELETE_ME',\n },\n getAppFiles(owner.root),\n new Set(), // no fastboot files\n extensionsPattern(resolver.options.resolvableExtensions),\n staticAppPathsPattern(resolver.options.staticAppPaths),\n resolver.options.podModulePrefix\n );\n\n let amdModules: { runtime: string; buildtime: string }[] = [];\n\n for (let relativePath of appFiles.tests) {\n amdModules.push(importPaths(resolver, appFiles, relativePath));\n }\n\n let src = entryTemplate({\n amdModules,\n });\n\n return {\n src,\n watches: [],\n };\n}\n\nconst entryTemplate = compile(`\nimport { importSync as i } from '@embroider/macros';\nlet w = window;\nlet d = w.define;\n\nimport \"ember-testing\";\nimport \"@embroider/core/entrypoint\";\n\n{{#each amdModules as |amdModule| ~}}\n d(\"{{js-string-escape amdModule.runtime}}\", function(){ return i(\"{{js-string-escape amdModule.buildtime}}\");});\n{{/each}}\n\nimport('./tests/test-helper');\nEmberENV.TESTS_FILE_LOADED = true;\n`) as (params: { amdModules: { runtime: string; buildtime: string }[] }) => string;\n"]}
|