@vorplex/compiler 0.0.64 → 0.0.65
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/dist/compiler.util.js
CHANGED
|
@@ -29,11 +29,14 @@ export class Compiler {
|
|
|
29
29
|
const task = options.task ?? new Task('Compile');
|
|
30
30
|
try {
|
|
31
31
|
task.log(`Compiling $[files] using entry file path (${options.entryFilePath})`, { attachments: { files: { type: 'yaml', value: stringify(options.files) } } });
|
|
32
|
+
const importOrigin = {};
|
|
32
33
|
return await Bundler.bundle({
|
|
33
34
|
path: options.entryFilePath,
|
|
34
35
|
script: options.files[options.entryFilePath].content,
|
|
35
36
|
sourcemaps: options.sourcemaps,
|
|
36
|
-
resolve: async ({ importerPath, importPath
|
|
37
|
+
resolve: async ({ importerPath, importPath }) => {
|
|
38
|
+
const origin = importerPath in options.files ? importerPath : importOrigin[importerPath] ?? importerPath;
|
|
39
|
+
importOrigin[importPath] ??= origin;
|
|
37
40
|
return await task.do(`Resolving: ${importPath}`, async (task) => {
|
|
38
41
|
if (importPath in options.files) {
|
|
39
42
|
task.log('Returning local file $[content]', { attachments: { content: { type: 'typescript', value: options.files[importPath].content } } });
|
|
@@ -66,7 +69,7 @@ export class Compiler {
|
|
|
66
69
|
}
|
|
67
70
|
}
|
|
68
71
|
try {
|
|
69
|
-
const dependencyTree = options.files[
|
|
72
|
+
const dependencyTree = options.files[origin]?.dependencyTree ?? options.files[importPath]?.dependencyTree ?? {};
|
|
70
73
|
const string = NPM.parseImportString(importPath);
|
|
71
74
|
task.log(`Package ${string.packageName} subpath ${string.subpath} version ${string.version}`);
|
|
72
75
|
if (!string.version) {
|
|
@@ -32,44 +32,34 @@ export class Bundler {
|
|
|
32
32
|
name: 'module-loader-resolver',
|
|
33
33
|
setup: (build) => {
|
|
34
34
|
const files = {};
|
|
35
|
-
const importParent = {};
|
|
36
|
-
const importPathAlias = {};
|
|
37
35
|
build.onResolve({ filter: /.*/ }, async (args) => {
|
|
38
36
|
const relative = args.path.startsWith('.') || args.path.startsWith('/');
|
|
39
37
|
const importerPath = args.importer === '<stdin>' ? options.path : args.importer;
|
|
40
38
|
const importPath = relative ? $Path.join(importerPath, `../${args.path}`) : args.path;
|
|
41
|
-
importParent[importPath] ??= importerPath;
|
|
42
|
-
let importStack = [];
|
|
43
|
-
const visited = new Set();
|
|
44
|
-
let parentPath = importerPath;
|
|
45
|
-
while (parentPath && !visited.has(parentPath)) {
|
|
46
|
-
visited.add(parentPath);
|
|
47
|
-
importStack.push(parentPath);
|
|
48
|
-
parentPath = importParent[importPathAlias[parentPath]] ?? importParent[parentPath];
|
|
49
|
-
}
|
|
50
39
|
const resolved = await options.resolve({
|
|
51
40
|
namespace: args.path,
|
|
52
41
|
importerPath,
|
|
53
42
|
importPath,
|
|
54
43
|
relative,
|
|
55
|
-
importStack
|
|
56
44
|
});
|
|
57
|
-
if (!resolved)
|
|
58
|
-
return { path: importPath, namespace: 'mock' };
|
|
59
|
-
if ('content' in resolved) {
|
|
60
|
-
files[resolved.path ?? importPath] = resolved.content;
|
|
61
|
-
if (resolved.path)
|
|
62
|
-
importPathAlias[resolved.path] = importPath;
|
|
45
|
+
if (!resolved) {
|
|
63
46
|
return {
|
|
64
|
-
path:
|
|
65
|
-
namespace: '
|
|
47
|
+
path: importPath,
|
|
48
|
+
namespace: 'mock',
|
|
66
49
|
};
|
|
67
50
|
}
|
|
68
|
-
|
|
51
|
+
if ('content' in resolved) {
|
|
52
|
+
const resolvedPath = resolved.path ?? importPath;
|
|
53
|
+
files[resolvedPath] = resolved.content;
|
|
69
54
|
return {
|
|
70
|
-
path:
|
|
71
|
-
|
|
55
|
+
path: resolvedPath,
|
|
56
|
+
namespace: 'virtual',
|
|
72
57
|
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
path: resolved.namespace,
|
|
61
|
+
external: true,
|
|
62
|
+
};
|
|
73
63
|
});
|
|
74
64
|
build.onLoad({ filter: /.*/, namespace: 'virtual' }, (args) => {
|
|
75
65
|
const loaders = {
|
|
@@ -93,8 +83,8 @@ export class Bundler {
|
|
|
93
83
|
},
|
|
94
84
|
],
|
|
95
85
|
sourcemap: options.sourcemaps ? 'inline' : false,
|
|
96
|
-
mainFields: ['module', 'main'],
|
|
97
|
-
conditions: ['import', 'module'],
|
|
86
|
+
mainFields: ['browser', 'module', 'main'],
|
|
87
|
+
conditions: ['browser', 'import', 'module'],
|
|
98
88
|
bundle: true,
|
|
99
89
|
format: 'cjs',
|
|
100
90
|
target: 'esnext',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vorplex/compiler",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.65",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
16
|
"main": "./dist/index.js",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"
|
|
18
|
+
"esbuild-wasm": "0.25.12",
|
|
19
19
|
"semver": "7.7.3",
|
|
20
20
|
"tslib": "2.8.1",
|
|
21
|
-
"
|
|
21
|
+
"@vorplex/core": "0.0.65",
|
|
22
22
|
"typescript": "5.9.3",
|
|
23
23
|
"yaml": "2.8.2"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
26
|
+
"vitest": "3.2.4",
|
|
27
|
+
"@types/semver": "7.7.1"
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc -b --force tsconfig.build.json",
|