@embroider/core 2.1.1-unstable.73213f2a → 2.1.1-unstable.936fd63
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 -3
- package/src/app-differ.d.ts +1 -1
- package/src/app-differ.js +21 -22
- package/src/app-differ.js.map +1 -1
- package/src/app-files.d.ts +0 -1
- package/src/app-files.js +0 -7
- package/src/app-files.js.map +1 -1
- package/src/app.js +12 -15
- package/src/app.js.map +1 -1
- package/src/describe-exports.d.ts +0 -1
- package/src/describe-exports.js +8 -9
- package/src/describe-exports.js.map +1 -1
- package/src/module-resolver.d.ts +5 -4
- package/src/module-resolver.js +245 -55
- package/src/module-resolver.js.map +1 -1
- package/src/options.d.ts +0 -1
- package/src/options.js.map +1 -1
- package/src/virtual-content.d.ts +6 -0
- package/src/virtual-content.js +45 -1
- package/src/virtual-content.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/example.d.ts +0 -2
- package/src/example.js +0 -20
- package/src/example.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/core",
|
|
3
|
-
"version": "2.1.1-unstable.
|
|
3
|
+
"version": "2.1.1-unstable.936fd63",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A build system for EmberJS applications.",
|
|
6
6
|
"repository": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"@babel/plugin-transform-runtime": "^7.14.5",
|
|
27
27
|
"@babel/runtime": "^7.14.5",
|
|
28
28
|
"@babel/traverse": "^7.14.5",
|
|
29
|
-
"@embroider/macros": "1.10.0-unstable.
|
|
30
|
-
"@embroider/shared-internals": "2.0.0-unstable.
|
|
29
|
+
"@embroider/macros": "1.10.0-unstable.936fd63",
|
|
30
|
+
"@embroider/shared-internals": "2.0.0-unstable.936fd63",
|
|
31
31
|
"assert-never": "^1.2.1",
|
|
32
32
|
"babel-plugin-ember-template-compilation": "^2.0.0",
|
|
33
33
|
"broccoli-node-api": "^1.7.0",
|
package/src/app-differ.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export default class AppDiffer {
|
|
|
6
6
|
private differ;
|
|
7
7
|
private sources;
|
|
8
8
|
private firstFastbootTree;
|
|
9
|
-
readonly files:
|
|
9
|
+
readonly files: Set<string>;
|
|
10
10
|
isFastbootOnly: Map<string, boolean>;
|
|
11
11
|
constructor(outputPath: string, ownAppJSDir: string, activeAddonDescendants: AddonPackage[], fastbootEnabled?: boolean, ownFastbootJSDir?: string | undefined, babelParserConfig?: TransformOptions | undefined);
|
|
12
12
|
update(): void;
|
package/src/app-differ.js
CHANGED
|
@@ -21,13 +21,8 @@ class AppDiffer {
|
|
|
21
21
|
this.outputPath = outputPath;
|
|
22
22
|
this.babelParserConfig = babelParserConfig;
|
|
23
23
|
this.firstFastbootTree = Infinity;
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
// resolution semantics so that each of the app files can still resolve
|
|
27
|
-
// relative to where it was authored.
|
|
28
|
-
//
|
|
29
|
-
// files authored within the app map to null
|
|
30
|
-
this.files = new Map();
|
|
24
|
+
// set of filenames logically located in the app
|
|
25
|
+
this.files = new Set();
|
|
31
26
|
// true for files that are fastboot-only.
|
|
32
27
|
this.isFastbootOnly = new Map();
|
|
33
28
|
this.sources = activeAddonDescendants.map(addon => maybeSource(addon, 'app-js')).filter(Boolean);
|
|
@@ -96,8 +91,10 @@ class AppDiffer {
|
|
|
96
91
|
this.isFastbootOnly.set(relativePath, sourceIndices[0] >= this.firstFastbootTree);
|
|
97
92
|
let source = this.sources[sourceIndices[0]];
|
|
98
93
|
let sourceFile = source.locate(relativePath);
|
|
99
|
-
(
|
|
100
|
-
|
|
94
|
+
if (!source.isRelocated) {
|
|
95
|
+
(0, fs_extra_1.copySync)(sourceFile, outputPath, { dereference: true });
|
|
96
|
+
}
|
|
97
|
+
this.updateFiles(relativePath);
|
|
101
98
|
}
|
|
102
99
|
else {
|
|
103
100
|
// we have both fastboot and non-fastboot files for this path.
|
|
@@ -110,10 +107,12 @@ class AppDiffer {
|
|
|
110
107
|
let base = (0, path_1.basename)(relativePath);
|
|
111
108
|
let browserDest = `_browser_${base}`;
|
|
112
109
|
let fastbootDest = `_fastboot_${base}`;
|
|
113
|
-
(
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
110
|
+
if (!browserSrc.isRelocated && !fastbootSrc.isRelocated) {
|
|
111
|
+
(0, fs_extra_1.copySync)(browserSourceFile, (0, path_1.join)(this.outputPath, dir, browserDest), { dereference: true });
|
|
112
|
+
(0, fs_extra_1.copySync)(fastbootSourceFile, (0, path_1.join)(this.outputPath, dir, fastbootDest), { dereference: true });
|
|
113
|
+
(0, fs_extra_1.writeFileSync)(outputPath, switcher(browserDest, fastbootDest, this.babelParserConfig, (0, fs_extra_1.readFileSync)(browserSourceFile, 'utf8')));
|
|
114
|
+
}
|
|
115
|
+
this.updateFiles(relativePath);
|
|
117
116
|
}
|
|
118
117
|
break;
|
|
119
118
|
default:
|
|
@@ -121,13 +120,8 @@ class AppDiffer {
|
|
|
121
120
|
}
|
|
122
121
|
}
|
|
123
122
|
}
|
|
124
|
-
updateFiles(relativePath
|
|
125
|
-
|
|
126
|
-
this.files.set(relativePath, sourceFile);
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
this.files.set(relativePath, null);
|
|
130
|
-
}
|
|
123
|
+
updateFiles(relativePath) {
|
|
124
|
+
this.files.add(relativePath);
|
|
131
125
|
}
|
|
132
126
|
}
|
|
133
127
|
exports.default = AppDiffer;
|
|
@@ -175,8 +169,13 @@ export const {{name}} = mod.{{name}};
|
|
|
175
169
|
{{/each}}
|
|
176
170
|
`);
|
|
177
171
|
function switcher(browserDest, fastbootDest, babelParserConfig, browserSource) {
|
|
178
|
-
let { names
|
|
179
|
-
return switcherTemplate({
|
|
172
|
+
let { names } = (0, describe_exports_1.describeExports)(browserSource, babelParserConfig);
|
|
173
|
+
return switcherTemplate({
|
|
174
|
+
fastbootDest,
|
|
175
|
+
browserDest,
|
|
176
|
+
names: [...names].filter(name => name !== 'default'),
|
|
177
|
+
hasDefaultExport: names.has('default'),
|
|
178
|
+
});
|
|
180
179
|
}
|
|
181
180
|
function maybeSource(addon, key) {
|
|
182
181
|
let maybeFiles = addon.meta[key];
|
package/src/app-differ.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-differ.js","sourceRoot":"","sources":["app-differ.ts"],"names":[],"mappings":";;;;;AACA,wEAA6D;AAC7D,0DAAiC;AACjC,+BAAwD;AACxD,uCAAgH;AAChH,yCAAmC;AACnC,gEAAuC;AACvC,yDAAqD;AACrD,mDAA0C;AAE1C,2BAA8B;AAC9B,+BAA8B;AAE9B,MAAqB,SAAS;IAgB5B,YACU,UAAkB,EAC1B,WAAmB,EACnB,sBAAsC;IACtC,wEAAwE;IACxE,4EAA4E;IAC5E,eAAe,GAAG,KAAK,EACvB,gBAAqC,EAC7B,iBAAgD;QAPhD,eAAU,GAAV,UAAU,CAAQ;QAOlB,sBAAiB,GAAjB,iBAAiB,CAA+B;QArBlD,sBAAiB,GAAG,QAAQ,CAAC;QAErC,8EAA8E;QAC9E,oEAAoE;QACpE,uEAAuE;QACvE,qCAAqC;QACrC,EAAE;QACF,4CAA4C;QACnC,UAAK,GAA+B,IAAI,GAAG,EAAE,CAAC;QAEvD,yCAAyC;QACzC,mBAAc,GAAyB,IAAI,GAAG,EAAE,CAAC;QAY/C,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAa,CAAC;QAE7G,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,SAAS,EAAE,IAAI;YACf,IAAI;gBAC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,CAAC;qBACX;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;YACD,WAAW,EAAE,IAAI;YACjB,MAAM,CAAC,YAAoB;gBACzB,IAAI,QAAQ,GAAG,KAAK,CAAC,IAAI,GAAG,YAAY,CAAC,CAAC;gBAC1C,IAAI,CAAC,QAAQ,EAAE;oBACb,MAAM,IAAI,KAAK,CAAC,sBAAsB,YAAY,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;iBACnF;gBACD,OAAO,IAAA,cAAO,EAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACvC,CAAC;SACF,CAAC;KACH;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,QAAgB,EAAE,SAAgB;IAClE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,GAAG,IAAA,aAAM,EAAC,SAAS,CAAC,KAAK,QAAQ,iCAAiC,CAAC,CAAC;KACrF;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { AddonPackage } from '@embroider/shared-internals';\nimport MultiTreeDiff, { InputTree } from './multi-tree-diff';\nimport walkSync from 'walk-sync';\nimport { join, basename, dirname, resolve } from 'path';\nimport { mkdirpSync, unlinkSync, rmdirSync, removeSync, copySync, writeFileSync, readFileSync } from 'fs-extra';\nimport { debug } from './messages';\nimport assertNever from 'assert-never';\nimport { describeExports } from './describe-exports';\nimport { compile } from './js-handlebars';\nimport { TransformOptions } from '@babel/core';\nimport { statSync } from 'fs';\nimport { format } from 'util';\n\nexport default class AppDiffer {\n private differ: MultiTreeDiff;\n private sources: Source[];\n private firstFastbootTree = Infinity;\n\n // maps from each filename in the app to the original directory from whence it\n // came, if it came from an addon. The mapping allows us to preserve\n // resolution semantics so that each of the app files can still resolve\n // relative to where it was authored.\n //\n // files authored within the app map to null\n readonly files: Map<string, string | null> = new Map();\n\n // true for files that are fastboot-only.\n isFastbootOnly: Map<string, boolean> = new Map();\n\n constructor(\n private outputPath: string,\n ownAppJSDir: string,\n activeAddonDescendants: AddonPackage[],\n // arguments below this point are only needed in fastboot mode. Fastboot\n // makes this pretty messy because fastboot trees all merge into the app 🤮.\n fastbootEnabled = false,\n ownFastbootJSDir?: string | undefined,\n private babelParserConfig?: TransformOptions | undefined\n ) {\n this.sources = activeAddonDescendants.map(addon => maybeSource(addon, 'app-js')).filter(Boolean) as Source[];\n\n this.sources.push({\n mayChange: true,\n walk() {\n return walkSync.entries(ownAppJSDir);\n },\n isRelocated: false,\n locate(relativePath: string) {\n return resolve(ownAppJSDir, relativePath);\n },\n });\n\n if (!fastbootEnabled) {\n this.differ = new MultiTreeDiff(this.sources, lastOneWins);\n return;\n }\n\n this.firstFastbootTree = this.sources.length;\n for (let addon of activeAddonDescendants) {\n let source = maybeSource(addon, 'fastboot-js');\n if (source) {\n this.sources.push(source);\n }\n }\n if (ownFastbootJSDir) {\n this.sources.push({\n mayChange: true,\n walk() {\n return walkSync.entries(ownFastbootJSDir);\n },\n isRelocated: false,\n locate(relativePath) {\n return resolve(ownFastbootJSDir, relativePath);\n },\n });\n }\n this.differ = new MultiTreeDiff(this.sources, fastbootMerge(this.firstFastbootTree));\n }\n\n update() {\n let { ops, sources } = this.differ.update();\n debug(`app-differ operations count: %s`, ops.length);\n for (let [operation, relativePath] of ops) {\n let outputPath = join(this.outputPath, relativePath);\n switch (operation) {\n case 'unlink':\n unlinkSync(outputPath);\n this.files.delete(relativePath);\n break;\n case 'rmdir':\n rmdirSync(outputPath);\n break;\n case 'mkdir':\n mkdirpSync(outputPath);\n break;\n case 'change':\n removeSync(outputPath);\n // deliberate fallthrough\n case 'create':\n let sourceIndices = sources.get(relativePath)!;\n if (sourceIndices.length === 1) {\n // a single file won. whether it's fastboot or non-fastboot doesn't\n // actually change what we do here. It gets emitted in the app's\n // namespace (if it's fastboot-only, non-fastboot code shouldn't be\n // trying to import it anyway, because that would have already been\n // an error pre-embroider).\n this.isFastbootOnly.set(relativePath, sourceIndices[0] >= this.firstFastbootTree);\n let source = this.sources[sourceIndices[0]];\n let sourceFile = source.locate(relativePath);\n copySync(sourceFile, outputPath, { dereference: true });\n this.updateFiles(relativePath, source, sourceFile);\n } else {\n // we have both fastboot and non-fastboot files for this path.\n // Because of the way fastbootMerge is written, the first one is the\n // non-fastboot.\n this.isFastbootOnly.set(relativePath, false);\n let [browserSrc, fastbootSrc] = sourceIndices.map(i => this.sources[i]);\n let [browserSourceFile, fastbootSourceFile] = [browserSrc, fastbootSrc].map(src =>\n src.locate(relativePath)\n );\n let dir = dirname(relativePath);\n let base = basename(relativePath);\n let browserDest = `_browser_${base}`;\n let fastbootDest = `_fastboot_${base}`;\n copySync(browserSourceFile, join(this.outputPath, dir, browserDest), { dereference: true });\n copySync(fastbootSourceFile, join(this.outputPath, dir, fastbootDest), { dereference: true });\n writeFileSync(\n outputPath,\n switcher(browserDest, fastbootDest, this.babelParserConfig!, readFileSync(browserSourceFile, 'utf8'))\n );\n this.updateFiles(relativePath, browserSrc, browserSourceFile);\n }\n break;\n default:\n assertNever(operation);\n }\n }\n }\n\n private updateFiles(relativePath: string, source: Source, sourceFile: string) {\n if (source.isRelocated) {\n this.files.set(relativePath, sourceFile);\n } else {\n this.files.set(relativePath, null);\n }\n }\n}\n\nfunction lastOneWins(treeIds: number[]) {\n return treeIds.slice(-1);\n}\n\nfunction fastbootMerge(firstFastbootTree: number) {\n return function _fastbootMerge(treeIds: number[]): number[] {\n let mainWinner, fastbootWinner;\n for (let id of treeIds) {\n if (id < firstFastbootTree) {\n mainWinner = id;\n } else {\n fastbootWinner = id;\n }\n }\n if (mainWinner != null && fastbootWinner != null) {\n return [mainWinner, fastbootWinner];\n } else if (mainWinner != null) {\n return [mainWinner];\n } else if (fastbootWinner != null) {\n return [fastbootWinner];\n } else {\n throw new Error(`bug: should always have at least one winner in fastbootMerge`);\n }\n };\n}\n\nconst switcherTemplate = compile(`\nimport { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\nlet mod;\nif (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n mod = importSync(\"./{{js-string-escape fastbootDest}}\");\n} else {\n mod = importSync(\"./{{js-string-escape browserDest}}\");\n}\n{{#if hasDefaultExport}}\nexport default mod.default;\n{{/if}}\n{{#each names as |name|}}\nexport const {{name}} = mod.{{name}};\n{{/each}}\n`) as (params: { fastbootDest: string; browserDest: string; names: string[]; hasDefaultExport: boolean }) => string;\n\nfunction switcher(\n browserDest: string,\n fastbootDest: string,\n babelParserConfig: TransformOptions,\n browserSource: string\n): string {\n let { names, hasDefaultExport } = describeExports(browserSource, babelParserConfig);\n return switcherTemplate({ fastbootDest, browserDest, names: [...names], hasDefaultExport });\n}\n\ninterface Source extends InputTree {\n // find the real on disk location of the file that is presented externally as\n // `relativePath`\n locate(relativePath: string): string;\n\n // true if this source relocates its file out of their original package,\n // meaning we will need to track them in order to adjust package resolution\n isRelocated: boolean;\n}\n\nfunction maybeSource(addon: AddonPackage, key: 'app-js' | 'fastboot-js'): Source | undefined {\n let maybeFiles = addon.meta[key];\n if (maybeFiles) {\n let files = maybeFiles;\n return {\n mayChange: addon.mayRebuild,\n walk() {\n return Object.entries(files).map(([externalName, internalName]) => {\n try {\n let stat = statSync(resolve(addon.root, internalName));\n return {\n relativePath: withoutMandatoryDotSlash(externalName, [\n 'in package.json at %s in key ember-addon.%s',\n addon.root,\n key,\n ]),\n mode: stat.mode,\n size: stat.size,\n mtime: stat.mtime,\n isDirectory() {\n return false;\n },\n };\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw new Error(\n `${addon.name}/package.json lists ${internalName} in ember-addon.${key}, but that file does not exist`\n );\n }\n throw err;\n }\n });\n },\n isRelocated: true,\n locate(relativePath: string) {\n let internal = files['./' + relativePath];\n if (!internal) {\n throw new Error(`bug: couldn't find ${relativePath} in ${JSON.stringify(files)}`);\n }\n return resolve(addon.root, internal);\n },\n };\n }\n}\n\nfunction withoutMandatoryDotSlash(filename: string, debugInfo: any[]): string {\n if (!filename.startsWith('./')) {\n throw new Error(`${format(debugInfo)}: ${filename} is required to start with \"./\"`);\n }\n return filename.slice(2);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"app-differ.js","sourceRoot":"","sources":["app-differ.ts"],"names":[],"mappings":";;;;;AACA,wEAA6D;AAC7D,0DAAiC;AACjC,+BAAwD;AACxD,uCAAgH;AAChH,yCAAmC;AACnC,gEAAuC;AACvC,yDAAqD;AACrD,mDAA0C;AAE1C,2BAA8B;AAC9B,+BAA8B;AAE9B,MAAqB,SAAS;IAW5B,YACU,UAAkB,EAC1B,WAAmB,EACnB,sBAAsC;IACtC,wEAAwE;IACxE,4EAA4E;IAC5E,eAAe,GAAG,KAAK,EACvB,gBAAqC,EAC7B,iBAAgD;QAPhD,eAAU,GAAV,UAAU,CAAQ;QAOlB,sBAAiB,GAAjB,iBAAiB,CAA+B;QAhBlD,sBAAiB,GAAG,QAAQ,CAAC;QAErC,gDAAgD;QACvC,UAAK,GAAgB,IAAI,GAAG,EAAE,CAAC;QAExC,yCAAyC;QACzC,mBAAc,GAAyB,IAAI,GAAG,EAAE,CAAC;QAY/C,IAAI,CAAC,OAAO,GAAG,sBAAsB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAa,CAAC;QAE7G,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YAChB,SAAS,EAAE,IAAI;YACf,IAAI;gBACF,OAAO,mBAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACvC,CAAC;YACD,WAAW,EAAE,KAAK;YAClB,MAAM,CAAC,YAAoB;gBACzB,OAAO,IAAA,cAAO,EAAC,WAAW,EAAE,YAAY,CAAC,CAAC;YAC5C,CAAC;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,eAAe,EAAE;YACpB,IAAI,CAAC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AO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;iBACnF;gBACD,OAAO,IAAA,cAAO,EAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACvC,CAAC;SACF,CAAC;KACH;AACH,CAAC;AAED,SAAS,wBAAwB,CAAC,QAAgB,EAAE,SAAgB;IAClE,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;QAC9B,MAAM,IAAI,KAAK,CAAC,GAAG,IAAA,aAAM,EAAC,SAAS,CAAC,KAAK,QAAQ,iCAAiC,CAAC,CAAC;KACrF;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { AddonPackage } from '@embroider/shared-internals';\nimport MultiTreeDiff, { InputTree } from './multi-tree-diff';\nimport walkSync from 'walk-sync';\nimport { join, basename, dirname, resolve } from 'path';\nimport { mkdirpSync, unlinkSync, rmdirSync, removeSync, copySync, writeFileSync, readFileSync } from 'fs-extra';\nimport { debug } from './messages';\nimport assertNever from 'assert-never';\nimport { describeExports } from './describe-exports';\nimport { compile } from './js-handlebars';\nimport { TransformOptions } from '@babel/core';\nimport { statSync } from 'fs';\nimport { format } from 'util';\n\nexport default class AppDiffer {\n private differ: MultiTreeDiff;\n private sources: Source[];\n private firstFastbootTree = Infinity;\n\n // set of filenames logically located in the app\n readonly files: Set<string> = new Set();\n\n // true for files that are fastboot-only.\n isFastbootOnly: Map<string, boolean> = new Map();\n\n constructor(\n private outputPath: string,\n ownAppJSDir: string,\n activeAddonDescendants: AddonPackage[],\n // arguments below this point are only needed in fastboot mode. Fastboot\n // makes this pretty messy because fastboot trees all merge into the app 🤮.\n fastbootEnabled = false,\n ownFastbootJSDir?: string | undefined,\n private babelParserConfig?: TransformOptions | undefined\n ) {\n this.sources = activeAddonDescendants.map(addon => maybeSource(addon, 'app-js')).filter(Boolean) as Source[];\n\n this.sources.push({\n mayChange: true,\n walk() {\n return walkSync.entries(ownAppJSDir);\n },\n isRelocated: false,\n locate(relativePath: string) {\n return resolve(ownAppJSDir, relativePath);\n },\n });\n\n if (!fastbootEnabled) {\n this.differ = new MultiTreeDiff(this.sources, lastOneWins);\n return;\n }\n\n this.firstFastbootTree = this.sources.length;\n for (let addon of activeAddonDescendants) {\n let source = maybeSource(addon, 'fastboot-js');\n if (source) {\n this.sources.push(source);\n }\n }\n if (ownFastbootJSDir) {\n this.sources.push({\n mayChange: true,\n walk() {\n return walkSync.entries(ownFastbootJSDir);\n },\n isRelocated: false,\n locate(relativePath) {\n return resolve(ownFastbootJSDir, relativePath);\n },\n });\n }\n this.differ = new MultiTreeDiff(this.sources, fastbootMerge(this.firstFastbootTree));\n }\n\n update() {\n let { ops, sources } = this.differ.update();\n debug(`app-differ operations count: %s`, ops.length);\n for (let [operation, relativePath] of ops) {\n let outputPath = join(this.outputPath, relativePath);\n switch (operation) {\n case 'unlink':\n unlinkSync(outputPath);\n this.files.delete(relativePath);\n break;\n case 'rmdir':\n rmdirSync(outputPath);\n break;\n case 'mkdir':\n mkdirpSync(outputPath);\n break;\n case 'change':\n removeSync(outputPath);\n // deliberate fallthrough\n case 'create':\n let sourceIndices = sources.get(relativePath)!;\n if (sourceIndices.length === 1) {\n // a single file won. whether it's fastboot or non-fastboot doesn't\n // actually change what we do here. It gets emitted in the app's\n // namespace (if it's fastboot-only, non-fastboot code shouldn't be\n // trying to import it anyway, because that would have already been\n // an error pre-embroider).\n this.isFastbootOnly.set(relativePath, sourceIndices[0] >= this.firstFastbootTree);\n let source = this.sources[sourceIndices[0]];\n let sourceFile = source.locate(relativePath);\n if (!source.isRelocated) {\n copySync(sourceFile, outputPath, { dereference: true });\n }\n this.updateFiles(relativePath);\n } else {\n // we have both fastboot and non-fastboot files for this path.\n // Because of the way fastbootMerge is written, the first one is the\n // non-fastboot.\n this.isFastbootOnly.set(relativePath, false);\n let [browserSrc, fastbootSrc] = sourceIndices.map(i => this.sources[i]);\n let [browserSourceFile, fastbootSourceFile] = [browserSrc, fastbootSrc].map(src =>\n src.locate(relativePath)\n );\n let dir = dirname(relativePath);\n let base = basename(relativePath);\n let browserDest = `_browser_${base}`;\n let fastbootDest = `_fastboot_${base}`;\n if (!browserSrc.isRelocated && !fastbootSrc.isRelocated) {\n copySync(browserSourceFile, join(this.outputPath, dir, browserDest), { dereference: true });\n copySync(fastbootSourceFile, join(this.outputPath, dir, fastbootDest), { dereference: true });\n writeFileSync(\n outputPath,\n switcher(browserDest, fastbootDest, this.babelParserConfig!, readFileSync(browserSourceFile, 'utf8'))\n );\n }\n this.updateFiles(relativePath);\n }\n break;\n default:\n assertNever(operation);\n }\n }\n }\n\n private updateFiles(relativePath: string) {\n this.files.add(relativePath);\n }\n}\n\nfunction lastOneWins(treeIds: number[]) {\n return treeIds.slice(-1);\n}\n\nfunction fastbootMerge(firstFastbootTree: number) {\n return function _fastbootMerge(treeIds: number[]): number[] {\n let mainWinner, fastbootWinner;\n for (let id of treeIds) {\n if (id < firstFastbootTree) {\n mainWinner = id;\n } else {\n fastbootWinner = id;\n }\n }\n if (mainWinner != null && fastbootWinner != null) {\n return [mainWinner, fastbootWinner];\n } else if (mainWinner != null) {\n return [mainWinner];\n } else if (fastbootWinner != null) {\n return [fastbootWinner];\n } else {\n throw new Error(`bug: should always have at least one winner in fastbootMerge`);\n }\n };\n}\n\nconst switcherTemplate = compile(`\nimport { macroCondition, getGlobalConfig, importSync } from '@embroider/macros';\nlet mod;\nif (macroCondition(getGlobalConfig().fastboot?.isRunning)){\n mod = importSync(\"./{{js-string-escape fastbootDest}}\");\n} else {\n mod = importSync(\"./{{js-string-escape browserDest}}\");\n}\n{{#if hasDefaultExport}}\nexport default mod.default;\n{{/if}}\n{{#each names as |name|}}\nexport const {{name}} = mod.{{name}};\n{{/each}}\n`) as (params: { fastbootDest: string; browserDest: string; names: string[]; hasDefaultExport: boolean }) => string;\n\nfunction switcher(\n browserDest: string,\n fastbootDest: string,\n babelParserConfig: TransformOptions,\n browserSource: string\n): string {\n let { names } = describeExports(browserSource, babelParserConfig);\n return switcherTemplate({\n fastbootDest,\n browserDest,\n names: [...names].filter(name => name !== 'default'),\n hasDefaultExport: names.has('default'),\n });\n}\n\ninterface Source extends InputTree {\n // find the real on disk location of the file that is presented externally as\n // `relativePath`\n locate(relativePath: string): string;\n\n // true if this source relocates its file out of their original package,\n // meaning we will need to track them in order to adjust package resolution\n isRelocated: boolean;\n}\n\nfunction maybeSource(addon: AddonPackage, key: 'app-js' | 'fastboot-js'): Source | undefined {\n let maybeFiles = addon.meta[key];\n if (maybeFiles) {\n let files = maybeFiles;\n return {\n mayChange: addon.mayRebuild,\n walk() {\n return Object.entries(files).map(([externalName, internalName]) => {\n try {\n let stat = statSync(resolve(addon.root, internalName));\n return {\n relativePath: withoutMandatoryDotSlash(externalName, [\n 'in package.json at %s in key ember-addon.%s',\n addon.root,\n key,\n ]),\n mode: stat.mode,\n size: stat.size,\n mtime: stat.mtime,\n isDirectory() {\n return false;\n },\n };\n } catch (err) {\n if (err.code === 'ENOENT') {\n throw new Error(\n `${addon.name}/package.json lists ${internalName} in ember-addon.${key}, but that file does not exist`\n );\n }\n throw err;\n }\n });\n },\n isRelocated: true,\n locate(relativePath: string) {\n let internal = files['./' + relativePath];\n if (!internal) {\n throw new Error(`bug: couldn't find ${relativePath} in ${JSON.stringify(files)}`);\n }\n return resolve(addon.root, internal);\n },\n };\n }\n}\n\nfunction withoutMandatoryDotSlash(filename: string, debugInfo: any[]): string {\n if (!filename.startsWith('./')) {\n throw new Error(`${format(debugInfo)}: ${filename} is required to start with \"./\"`);\n }\n return filename.slice(2);\n}\n"]}
|
package/src/app-files.d.ts
CHANGED
|
@@ -13,7 +13,6 @@ export declare class AppFiles {
|
|
|
13
13
|
readonly modifiers: ReadonlyArray<string>;
|
|
14
14
|
private perRoute;
|
|
15
15
|
readonly otherAppFiles: ReadonlyArray<string>;
|
|
16
|
-
readonly relocatedFiles: Map<string, string>;
|
|
17
16
|
readonly isFastbootOnly: Map<string, boolean>;
|
|
18
17
|
constructor(appDiffer: AppDiffer, resolvableExtensions: RegExp, podModulePrefix?: string);
|
|
19
18
|
private handleClassicRouteFile;
|
package/src/app-files.js
CHANGED
|
@@ -57,13 +57,6 @@ class AppFiles {
|
|
|
57
57
|
this.helpers = helpers;
|
|
58
58
|
this.modifiers = modifiers;
|
|
59
59
|
this.otherAppFiles = otherAppFiles;
|
|
60
|
-
let relocatedFiles = new Map();
|
|
61
|
-
for (let [relativePath, owningPath] of appDiffer.files) {
|
|
62
|
-
if (owningPath) {
|
|
63
|
-
relocatedFiles.set(relativePath, owningPath);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
this.relocatedFiles = relocatedFiles;
|
|
67
60
|
this.isFastbootOnly = appDiffer.isFastbootOnly;
|
|
68
61
|
}
|
|
69
62
|
handleClassicRouteFile(relativePath) {
|
package/src/app-files.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app-files.js","sourceRoot":"","sources":["app-files.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAW3B,MAAa,QAAQ;
|
|
1
|
+
{"version":3,"file":"app-files.js","sourceRoot":"","sources":["app-files.ts"],"names":[],"mappings":";;;AAAA,+BAA2B;AAW3B,MAAa,QAAQ;IASnB,YAAY,SAAoB,EAAE,oBAA4B,EAAE,eAAwB;QACtF,IAAI,KAAK,GAAa,EAAE,CAAC;QACzB,IAAI,UAAU,GAAa,EAAE,CAAC;QAC9B,IAAI,OAAO,GAAa,EAAE,CAAC;QAC3B,IAAI,SAAS,GAAa,EAAE,CAAC;QAC7B,IAAI,aAAa,GAAa,EAAE,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;QACxC,KAAK,IAAI,YAAY,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE;YAC/C,YAAY,GAAG,YAAY,CAAC,KAAK,CAAC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AAI,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9D,IAAI,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,IAAI,IAAI,CAAC,CAAC,YAAY,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAChE,OAAO,KAAK,CAAC;SACd;QACD,IAAI,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1C,8DAA8D;QAC9D,QAAQ,CAAC,KAAK,EAAE,CAAC;QAEjB,KAAK,IAAI,OAAO,IAAI,QAAQ,EAAE;YAC5B,IAAI,KAAK,CAAC,KAAK,EAAE,KAAK,OAAO,EAAE;gBAC7B,OAAO,KAAK,CAAC;aACd;SACF;QAED,IAAI,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC;QAC3B,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YACtB,IAAI,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,KAAK,EAAE;gBACT,MAAM,GAAG,KAAK,CAAC;aAChB;iBAAM;gBACL,IAAI,QAAQ,GAAG,EAAE,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,CAAC;gBACvC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;gBACpC,MAAM,GAAG,QAAQ,CAAC;aACnB;SACF;QACD,MAAM,CAAC,IAA2C,CAAC,GAAG,YAAY,CAAC;QACnE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAnID,4BAmIC","sourcesContent":["import { sep } from 'path';\nimport { Package, AddonPackage } from '@embroider/shared-internals';\nimport type AppDiffer from './app-differ';\n\nexport interface RouteFiles {\n route?: string;\n template?: string;\n controller?: string;\n children: Map<string, RouteFiles>;\n}\n\nexport class AppFiles {\n readonly tests: ReadonlyArray<string>;\n readonly components: ReadonlyArray<string>;\n readonly helpers: ReadonlyArray<string>;\n readonly modifiers: ReadonlyArray<string>;\n private perRoute: RouteFiles;\n readonly otherAppFiles: ReadonlyArray<string>;\n readonly isFastbootOnly: Map<string, boolean>;\n\n constructor(appDiffer: AppDiffer, resolvableExtensions: RegExp, podModulePrefix?: string) {\n let tests: string[] = [];\n let components: string[] = [];\n let helpers: string[] = [];\n let modifiers: string[] = [];\n let otherAppFiles: string[] = [];\n this.perRoute = { children: new Map() };\n for (let relativePath of appDiffer.files.keys()) {\n relativePath = relativePath.split(sep).join('/');\n if (!resolvableExtensions.test(relativePath)) {\n continue;\n }\n\n if (/\\.d\\.ts$/.test(relativePath)) {\n // .d.ts files are technically \"*.ts\" files but aren't really and we\n // don't want to include them when we crawl through the app.\n continue;\n }\n\n if (relativePath.startsWith('tests/')) {\n tests.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('components/')) {\n // hbs files are resolvable, but not when they're used via co-location.\n // An hbs file is used via colocation when it's inside the components\n // directory, and also not named \"template.hbs\" (because that is an\n // older pattern used with pods-like layouts).\n if (!relativePath.endsWith('.hbs') || relativePath.endsWith('/template.hbs')) {\n components.push(relativePath);\n }\n continue;\n }\n\n if (relativePath.startsWith('templates/components/')) {\n components.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('helpers/')) {\n helpers.push(relativePath);\n continue;\n }\n\n if (relativePath.startsWith('modifiers/')) {\n modifiers.push(relativePath);\n continue;\n }\n\n if (\n this.handleClassicRouteFile(relativePath) ||\n (podModulePrefix !== undefined && this.handlePodsRouteFile(relativePath, podModulePrefix))\n ) {\n continue;\n }\n\n otherAppFiles.push(relativePath);\n }\n this.tests = tests;\n this.components = components;\n this.helpers = helpers;\n this.modifiers = modifiers;\n this.otherAppFiles = otherAppFiles;\n this.isFastbootOnly = appDiffer.isFastbootOnly;\n }\n\n private handleClassicRouteFile(relativePath: string): boolean {\n let [prefix, ...rest] = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n if (!['controllers', 'templates', 'routes'].includes(prefix)) {\n return false;\n }\n let type = prefix.slice(0, -1) as 'controller' | 'template' | 'route';\n let cursor = this.perRoute;\n for (let part of rest) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type] = relativePath;\n return true;\n }\n\n private handlePodsRouteFile(relativePath: string, podModulePrefix: string): boolean {\n let parts = relativePath.replace(/\\.\\w{1,3}$/, '').split('/');\n let type = parts.pop();\n if (!type || !['controller', 'template', 'route'].includes(type)) {\n return false;\n }\n let podParts = podModulePrefix.split('/');\n // The first part of podModulePrefix is the app's package name\n podParts.shift();\n\n for (let podPart of podParts) {\n if (parts.shift() !== podPart) {\n return false;\n }\n }\n\n let cursor = this.perRoute;\n for (let part of parts) {\n let child = cursor.children.get(part);\n if (child) {\n cursor = child;\n } else {\n let newEntry = { children: new Map() };\n cursor.children.set(part, newEntry);\n cursor = newEntry;\n }\n }\n cursor[type as 'controller' | 'template' | 'route'] = relativePath;\n return true;\n }\n\n get routeFiles(): Readonly<RouteFiles> {\n return this.perRoute;\n }\n}\n\nexport interface EngineSummary {\n // the engine's own package\n package: Package;\n // the set of active addons in the engine\n addons: Set<AddonPackage>;\n // the parent engine, if any\n parent: EngineSummary | undefined;\n // where the engine's own V2 code comes from\n sourcePath: string;\n // where the engine gets built into, combining its own code with all its\n // addons\n destPath: string;\n // runtime name for the engine's own module namespace\n modulePrefix: string;\n // this is destPath but relative to the app itself\n appRelativePath: string;\n}\n\nexport interface Engine extends EngineSummary {\n appFiles: AppFiles;\n}\n"]}
|
package/src/app.js
CHANGED
|
@@ -905,16 +905,16 @@ class AppBuilder {
|
|
|
905
905
|
}
|
|
906
906
|
lazyRoutes.push({
|
|
907
907
|
names: routeNames,
|
|
908
|
-
path: this.importPaths(engine, routeEntrypoint
|
|
908
|
+
path: this.importPaths(engine, routeEntrypoint).buildtime,
|
|
909
909
|
});
|
|
910
910
|
});
|
|
911
911
|
}
|
|
912
912
|
let [fastboot, nonFastboot] = (0, partition_1.default)(excludeDotFiles((0, flatten_1.default)(requiredAppFiles)), file => appFiles.isFastbootOnly.get(file));
|
|
913
|
-
let amdModules = nonFastboot.map(file => this.importPaths(engine, file
|
|
914
|
-
let fastbootOnlyAmdModules = fastboot.map(file => this.importPaths(engine, file
|
|
913
|
+
let amdModules = nonFastboot.map(file => this.importPaths(engine, file));
|
|
914
|
+
let fastbootOnlyAmdModules = fastboot.map(file => this.importPaths(engine, file));
|
|
915
915
|
// this is a backward-compatibility feature: addons can force inclusion of
|
|
916
916
|
// modules.
|
|
917
|
-
this.gatherImplicitModules('implicit-modules',
|
|
917
|
+
this.gatherImplicitModules('implicit-modules', engine, amdModules);
|
|
918
918
|
let params = { amdModules, fastbootOnlyAmdModules, lazyRoutes, lazyEngines, eagerModules, styles };
|
|
919
919
|
if (entryParams) {
|
|
920
920
|
Object.assign(params, entryParams);
|
|
@@ -931,12 +931,11 @@ class AppBuilder {
|
|
|
931
931
|
get modulePrefix() {
|
|
932
932
|
return this.adapter.modulePrefix();
|
|
933
933
|
}
|
|
934
|
-
importPaths(engine, engineRelativePath
|
|
935
|
-
let appRelativePath = (0, path_1.join)(engine.appRelativePath, engineRelativePath);
|
|
934
|
+
importPaths(engine, engineRelativePath) {
|
|
936
935
|
let noHBS = engineRelativePath.replace(this.resolvableExtensionsPattern, '').replace(/\.hbs$/, '');
|
|
937
936
|
return {
|
|
938
937
|
runtime: `${engine.modulePrefix}/${noHBS}`,
|
|
939
|
-
buildtime:
|
|
938
|
+
buildtime: path_1.posix.join(engine.package.name, engineRelativePath),
|
|
940
939
|
};
|
|
941
940
|
}
|
|
942
941
|
routeEntrypoint(engine, relativePath, files) {
|
|
@@ -944,8 +943,8 @@ class AppBuilder {
|
|
|
944
943
|
let asset = {
|
|
945
944
|
kind: 'in-memory',
|
|
946
945
|
source: routeEntryTemplate({
|
|
947
|
-
files: nonFastboot.map(f => this.importPaths(engine, f
|
|
948
|
-
fastbootOnlyFiles: fastboot.map(f => this.importPaths(engine, f
|
|
946
|
+
files: nonFastboot.map(f => this.importPaths(engine, f)),
|
|
947
|
+
fastbootOnlyFiles: fastboot.map(f => this.importPaths(engine, f)),
|
|
949
948
|
}),
|
|
950
949
|
relativePath,
|
|
951
950
|
};
|
|
@@ -972,10 +971,10 @@ class AppBuilder {
|
|
|
972
971
|
let amdModules = [];
|
|
973
972
|
// this is a backward-compatibility feature: addons can force inclusion of
|
|
974
973
|
// test support modules.
|
|
975
|
-
this.gatherImplicitModules('implicit-test-modules',
|
|
974
|
+
this.gatherImplicitModules('implicit-test-modules', engine, amdModules);
|
|
976
975
|
let { appFiles } = engine;
|
|
977
976
|
for (let relativePath of appFiles.tests) {
|
|
978
|
-
amdModules.push(this.importPaths(engine, relativePath
|
|
977
|
+
amdModules.push(this.importPaths(engine, relativePath));
|
|
979
978
|
}
|
|
980
979
|
let source = entryTemplate({
|
|
981
980
|
amdModules,
|
|
@@ -990,7 +989,7 @@ class AppBuilder {
|
|
|
990
989
|
prepared.set(asset.relativePath, asset);
|
|
991
990
|
return asset;
|
|
992
991
|
}
|
|
993
|
-
gatherImplicitModules(section,
|
|
992
|
+
gatherImplicitModules(section, engine, lazyModules) {
|
|
994
993
|
for (let addon of engine.addons) {
|
|
995
994
|
let implicitModules = addon.meta[section];
|
|
996
995
|
if (implicitModules) {
|
|
@@ -1015,9 +1014,7 @@ class AppBuilder {
|
|
|
1015
1014
|
runtime = runtime.split(path_1.sep).join('/');
|
|
1016
1015
|
lazyModules.push({
|
|
1017
1016
|
runtime,
|
|
1018
|
-
buildtime:
|
|
1019
|
-
? (0, path_1.join)(packageName, name)
|
|
1020
|
-
: (0, shared_internals_1.explicitRelative)((0, path_1.dirname)((0, path_1.join)(this.root, relativeTo)), (0, path_1.join)(addon.root, name)),
|
|
1017
|
+
buildtime: path_1.posix.join(packageName, name),
|
|
1021
1018
|
});
|
|
1022
1019
|
}
|
|
1023
1020
|
}
|