@embroider/core 3.4.4-unstable.ecb0185 → 3.4.4
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/LICENSE +21 -0
- package/package.json +11 -12
- package/src/app-files.d.ts +1 -1
- package/src/app-files.js +1 -1
- package/src/app-files.js.map +1 -1
- package/src/module-resolver.d.ts +3 -5
- package/src/module-resolver.js +132 -126
- package/src/module-resolver.js.map +1 -1
- package/src/virtual-content.js +3 -6
- package/src/virtual-content.js.map +1 -1
- package/src/node-resolve.d.ts +0 -26
- package/src/node-resolve.js +0 -105
- package/src/node-resolve.js.map +0 -1
package/src/node-resolve.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.nodeResolve = exports.NodeModuleRequest = void 0;
|
|
7
|
-
const virtual_content_1 = require("./virtual-content");
|
|
8
|
-
const path_1 = require("path");
|
|
9
|
-
const shared_internals_1 = require("@embroider/shared-internals");
|
|
10
|
-
const assert_never_1 = __importDefault(require("assert-never"));
|
|
11
|
-
class NodeModuleRequest {
|
|
12
|
-
constructor(specifier, fromFile, isVirtual, meta, isNotFound) {
|
|
13
|
-
this.specifier = specifier;
|
|
14
|
-
this.fromFile = fromFile;
|
|
15
|
-
this.isVirtual = isVirtual;
|
|
16
|
-
this.meta = meta;
|
|
17
|
-
this.isNotFound = isNotFound;
|
|
18
|
-
}
|
|
19
|
-
get debugType() {
|
|
20
|
-
return 'node';
|
|
21
|
-
}
|
|
22
|
-
alias(specifier) {
|
|
23
|
-
return new NodeModuleRequest(specifier, this.fromFile, false, this.meta, false);
|
|
24
|
-
}
|
|
25
|
-
rehome(fromFile) {
|
|
26
|
-
if (this.fromFile === fromFile) {
|
|
27
|
-
return this;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
return new NodeModuleRequest(this.specifier, fromFile, false, this.meta, false);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
virtualize(filename) {
|
|
34
|
-
return new NodeModuleRequest(filename, this.fromFile, true, this.meta, false);
|
|
35
|
-
}
|
|
36
|
-
withMeta(meta) {
|
|
37
|
-
return new NodeModuleRequest(this.specifier, this.fromFile, this.isVirtual, meta, this.isNotFound);
|
|
38
|
-
}
|
|
39
|
-
notFound() {
|
|
40
|
-
return new NodeModuleRequest(this.specifier, this.fromFile, this.isVirtual, this.meta, true);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.NodeModuleRequest = NodeModuleRequest;
|
|
44
|
-
function nodeResolve(resolver, specifier, fromFile) {
|
|
45
|
-
let resolution = resolver.resolveSync(new NodeModuleRequest(specifier, fromFile, false, undefined, false), request => {
|
|
46
|
-
if (request.isVirtual) {
|
|
47
|
-
return {
|
|
48
|
-
type: 'found',
|
|
49
|
-
result: {
|
|
50
|
-
type: 'virtual',
|
|
51
|
-
content: (0, virtual_content_1.virtualContent)(request.specifier, resolver),
|
|
52
|
-
filename: request.specifier,
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
if (request.isNotFound) {
|
|
57
|
-
let err = new Error(`module not found ${request.specifier}`);
|
|
58
|
-
err.code = 'MODULE_NOT_FOUND';
|
|
59
|
-
return {
|
|
60
|
-
type: 'not_found',
|
|
61
|
-
err,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
try {
|
|
65
|
-
// require.resolve does not like when we resolve from virtual paths.
|
|
66
|
-
// That is, a request like "../thing.js" from
|
|
67
|
-
// "/a/real/path/VIRTUAL_SUBDIR/virtual.js" has an unambiguous target of
|
|
68
|
-
// "/a/real/path/thing.js", but require.resolve won't do that path
|
|
69
|
-
// adjustment until after checking whether VIRTUAL_SUBDIR actually
|
|
70
|
-
// exists.
|
|
71
|
-
//
|
|
72
|
-
// We can do the path adjustments before doing require.resolve.
|
|
73
|
-
let { specifier } = request;
|
|
74
|
-
let fromDir = (0, path_1.dirname)(request.fromFile);
|
|
75
|
-
if (!(0, path_1.isAbsolute)(specifier) && specifier.startsWith('.')) {
|
|
76
|
-
let targetPath = (0, path_1.resolve)(fromDir, specifier);
|
|
77
|
-
let newFromDir = (0, path_1.dirname)(targetPath);
|
|
78
|
-
if (fromDir !== newFromDir) {
|
|
79
|
-
specifier = (0, shared_internals_1.explicitRelative)(newFromDir, targetPath);
|
|
80
|
-
fromDir = newFromDir;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
let filename = require.resolve(specifier, {
|
|
84
|
-
paths: [fromDir],
|
|
85
|
-
});
|
|
86
|
-
return { type: 'found', result: { type: 'real', filename } };
|
|
87
|
-
}
|
|
88
|
-
catch (err) {
|
|
89
|
-
if (err.code !== 'MODULE_NOT_FOUND') {
|
|
90
|
-
throw err;
|
|
91
|
-
}
|
|
92
|
-
return { type: 'not_found', err };
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
switch (resolution.type) {
|
|
96
|
-
case 'not_found':
|
|
97
|
-
return resolution;
|
|
98
|
-
case 'found':
|
|
99
|
-
return resolution.result;
|
|
100
|
-
default:
|
|
101
|
-
throw (0, assert_never_1.default)(resolution);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.nodeResolve = nodeResolve;
|
|
105
|
-
//# sourceMappingURL=node-resolve.js.map
|
package/src/node-resolve.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"node-resolve.js","sourceRoot":"","sources":["node-resolve.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAmD;AACnD,+BAAoD;AACpD,kEAA+D;AAC/D,gEAAuC;AAKvC,MAAa,iBAAiB;IAC5B,YACW,SAAiB,EACjB,QAAgB,EAChB,SAAkB,EAClB,IAAqC,EACrC,UAAmB;QAJnB,cAAS,GAAT,S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AAU,CAAC;iBACtB;aACF;YAED,IAAI,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE;gBACxC,KAAK,EAAE,CAAC,OAAO,CAAC;aACjB,CAAC,CAAC;YACH,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,MAAgB,EAAE,QAAQ,EAAE,EAAE,CAAC;SACxE;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB,EAAE;gBACnC,MAAM,GAAG,CAAC;aACX;YACD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC;SACnC;IACH,CAAC,CACF,CAAC;IACF,QAAQ,UAAU,CAAC,IAAI,EAAE;QACvB,KAAK,WAAW;YACd,OAAO,UAAU,CAAC;QACpB,KAAK,OAAO;YACV,OAAO,UAAU,CAAC,MAAM,CAAC;QAC3B;YACE,MAAM,IAAA,sBAAW,EAAC,UAAU,CAAC,CAAC;KACjC;AACH,CAAC;AArED,kCAqEC","sourcesContent":["import { virtualContent } from './virtual-content';\nimport { dirname, resolve, isAbsolute } from 'path';\nimport { explicitRelative } from '@embroider/shared-internals';\nimport assertNever from 'assert-never';\n\n// these would be circular, but they're type-only so it's fine\nimport type { ModuleRequest, Resolver } from './module-resolver';\n\nexport class NodeModuleRequest implements ModuleRequest {\n constructor(\n readonly specifier: string,\n readonly fromFile: string,\n readonly isVirtual: boolean,\n readonly meta: Record<string, any> | undefined,\n readonly isNotFound: boolean\n ) {}\n\n get debugType() {\n return 'node';\n }\n\n alias(specifier: string): this {\n return new NodeModuleRequest(specifier, this.fromFile, false, this.meta, false) as this;\n }\n rehome(fromFile: string): this {\n if (this.fromFile === fromFile) {\n return this;\n } else {\n return new NodeModuleRequest(this.specifier, fromFile, false, this.meta, false) as this;\n }\n }\n virtualize(filename: string): this {\n return new NodeModuleRequest(filename, this.fromFile, true, this.meta, false) as this;\n }\n withMeta(meta: Record<string, any> | undefined): this {\n return new NodeModuleRequest(this.specifier, this.fromFile, this.isVirtual, meta, this.isNotFound) as this;\n }\n notFound(): this {\n return new NodeModuleRequest(this.specifier, this.fromFile, this.isVirtual, this.meta, true) as this;\n }\n}\n\nexport function nodeResolve(\n resolver: Resolver,\n specifier: string,\n fromFile: string\n):\n | { type: 'virtual'; filename: string; content: string }\n | { type: 'real'; filename: string }\n | { type: 'not_found'; err: Error } {\n let resolution = resolver.resolveSync(\n new NodeModuleRequest(specifier, fromFile, false, undefined, false),\n request => {\n if (request.isVirtual) {\n return {\n type: 'found',\n result: {\n type: 'virtual' as 'virtual',\n content: virtualContent(request.specifier, resolver),\n filename: request.specifier,\n },\n };\n }\n if (request.isNotFound) {\n let err = new Error(`module not found ${request.specifier}`);\n (err as any).code = 'MODULE_NOT_FOUND';\n return {\n type: 'not_found',\n err,\n };\n }\n try {\n // require.resolve does not like when we resolve from virtual paths.\n // That is, a request like \"../thing.js\" from\n // \"/a/real/path/VIRTUAL_SUBDIR/virtual.js\" has an unambiguous target of\n // \"/a/real/path/thing.js\", but require.resolve won't do that path\n // adjustment until after checking whether VIRTUAL_SUBDIR actually\n // exists.\n //\n // We can do the path adjustments before doing require.resolve.\n let { specifier } = request;\n let fromDir = dirname(request.fromFile);\n if (!isAbsolute(specifier) && specifier.startsWith('.')) {\n let targetPath = resolve(fromDir, specifier);\n let newFromDir = dirname(targetPath);\n if (fromDir !== newFromDir) {\n specifier = explicitRelative(newFromDir, targetPath);\n fromDir = newFromDir;\n }\n }\n\n let filename = require.resolve(specifier, {\n paths: [fromDir],\n });\n return { type: 'found', result: { type: 'real' as 'real', filename } };\n } catch (err) {\n if (err.code !== 'MODULE_NOT_FOUND') {\n throw err;\n }\n return { type: 'not_found', err };\n }\n }\n );\n switch (resolution.type) {\n case 'not_found':\n return resolution;\n case 'found':\n return resolution.result;\n default:\n throw assertNever(resolution);\n }\n}\n"]}
|