@esmx/core 3.0.0-rc.59 → 3.0.0-rc.62
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/app.d.ts +27 -27
- package/dist/core.d.ts +274 -272
- package/dist/core.mjs +237 -235
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +0 -6
- package/dist/manifest-json.d.ts +8 -21
- package/dist/module-config.d.ts +39 -144
- package/dist/module-config.mjs +145 -57
- package/dist/module-config.test.mjs +620 -509
- package/dist/pack-config.d.ts +94 -94
- package/dist/render-context.d.ts +465 -465
- package/dist/render-context.mjs +338 -338
- package/dist/utils/cache.d.ts +15 -15
- package/dist/utils/import-map.d.ts +9 -5
- package/dist/utils/import-map.mjs +36 -23
- package/dist/utils/import-map.test.mjs +1139 -103
- package/dist/utils/middleware.d.ts +19 -19
- package/dist/utils/static-import-lexer.d.ts +12 -12
- package/dist/utils/static-import-lexer.mjs +1 -1
- package/package.json +3 -3
- package/src/app.ts +34 -34
- package/src/core.ts +323 -320
- package/src/index.ts +14 -9
- package/src/manifest-json.ts +8 -22
- package/src/module-config.test.ts +636 -637
- package/src/module-config.ts +242 -257
- package/src/pack-config.ts +94 -94
- package/src/render-context.ts +465 -465
- package/src/utils/cache.ts +15 -15
- package/src/utils/import-map.test.ts +1207 -110
- package/src/utils/import-map.ts +63 -29
- package/src/utils/middleware.ts +19 -19
- package/src/utils/static-import-lexer.ts +18 -18
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { type EsmxOptions, type COMMAND, type BuildEnvironment, type ImportMap, type SpecifierMap, type ScopesMap, Esmx } from './core';
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
2
|
+
export type { ModuleConfig, ModuleConfigImportMapping, ModuleConfigExportExports, ModuleConfigExportExport, ModuleConfigExportObject, ParsedModuleConfig, ParsedModuleConfigExports, ParsedModuleConfigExport, ParsedModuleConfigEnvironment, ParsedModuleConfigLink } from './module-config';
|
|
3
|
+
export type { PackConfig, ParsedPackConfig } from './pack-config';
|
|
4
4
|
export { type App, createApp } from './app';
|
|
5
5
|
export { type RenderContextOptions, type ServerRenderHandle, type RenderFiles, RenderContext } from './render-context';
|
|
6
6
|
export { isImmutableFile, type Middleware, createMiddleware, mergeMiddlewares } from './utils/middleware';
|
|
7
|
-
export type { ManifestJson, ManifestJsonChunk,
|
|
7
|
+
export type { ManifestJson, ManifestJsonChunk, ManifestJsonChunks, ManifestJsonExport, ManifestJsonExports } from './manifest-json';
|
package/dist/index.mjs
CHANGED
package/dist/manifest-json.d.ts
CHANGED
|
@@ -9,15 +9,20 @@ export interface ManifestJson {
|
|
|
9
9
|
* Import mappings
|
|
10
10
|
*/
|
|
11
11
|
imports: Record<string, string>;
|
|
12
|
+
/**
|
|
13
|
+
* Scope-specific import mappings
|
|
14
|
+
* Type: Record<scope name, import mappings within that scope>
|
|
15
|
+
*/
|
|
16
|
+
scopes: Record<string, Record<string, string>>;
|
|
12
17
|
/**
|
|
13
18
|
* Export item configuration
|
|
14
19
|
* Type: Record<export path, export item information>
|
|
15
20
|
*/
|
|
16
21
|
exports: ManifestJsonExports;
|
|
17
22
|
/**
|
|
18
|
-
* Build output
|
|
23
|
+
* Build output files
|
|
19
24
|
*/
|
|
20
|
-
|
|
25
|
+
files: string[];
|
|
21
26
|
/**
|
|
22
27
|
* Compiled file information
|
|
23
28
|
* Type: Record<source file, compilation information>
|
|
@@ -42,7 +47,7 @@ export interface ManifestJsonExport {
|
|
|
42
47
|
* - true: Rewrite to '{serviceName}/{exportName}' format
|
|
43
48
|
* - false: Maintain original import paths
|
|
44
49
|
*/
|
|
45
|
-
|
|
50
|
+
pkg: boolean;
|
|
46
51
|
/**
|
|
47
52
|
* File path corresponding to the export item
|
|
48
53
|
*/
|
|
@@ -67,24 +72,6 @@ export interface ManifestJsonChunk {
|
|
|
67
72
|
* Other resource files.
|
|
68
73
|
*/
|
|
69
74
|
resources: string[];
|
|
70
|
-
/**
|
|
71
|
-
* Build output sizes.
|
|
72
|
-
*/
|
|
73
|
-
sizes: ManifestJsonChunkSizes;
|
|
74
|
-
}
|
|
75
|
-
export interface ManifestJsonChunkSizes {
|
|
76
|
-
/**
|
|
77
|
-
* JavaScript file size in bytes
|
|
78
|
-
*/
|
|
79
|
-
js: number;
|
|
80
|
-
/**
|
|
81
|
-
* CSS file size in bytes
|
|
82
|
-
*/
|
|
83
|
-
css: number;
|
|
84
|
-
/**
|
|
85
|
-
* Resource file size in bytes
|
|
86
|
-
*/
|
|
87
|
-
resource: number;
|
|
88
75
|
}
|
|
89
76
|
/**
|
|
90
77
|
* Get service manifest files
|
package/dist/module-config.d.ts
CHANGED
|
@@ -1,158 +1,53 @@
|
|
|
1
1
|
import type { BuildEnvironment } from './core';
|
|
2
|
-
/**
|
|
3
|
-
* Core configuration interface for the module system.
|
|
4
|
-
* Defines module linking, import mapping, and export configurations.
|
|
5
|
-
*/
|
|
6
2
|
export interface ModuleConfig {
|
|
7
|
-
/**
|
|
8
|
-
* Module linking configuration.
|
|
9
|
-
* Key is remote module name, value is module build output directory path.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* links: {
|
|
14
|
-
* 'shared-lib': '../shared-lib/dist',
|
|
15
|
-
* 'api-utils': '/var/www/api-utils/dist'
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
3
|
links?: Record<string, string>;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* Key is local module identifier, value is remote module path.
|
|
23
|
-
* Mainly used for standard imports of third-party libraries.
|
|
24
|
-
*
|
|
25
|
-
* @example
|
|
26
|
-
* ```typescript
|
|
27
|
-
* imports: {
|
|
28
|
-
* 'axios': 'shared-lib/axios',
|
|
29
|
-
* 'lodash': 'shared-lib/lodash'
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
imports?: Record<string, string>;
|
|
34
|
-
/**
|
|
35
|
-
* Module export configuration.
|
|
36
|
-
* Supports multiple configuration forms: mixed array and object.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* // Array form
|
|
41
|
-
* exports: ['npm:axios', 'root:src/utils/format.ts']
|
|
42
|
-
*
|
|
43
|
-
* // Object form
|
|
44
|
-
* exports: {
|
|
45
|
-
* 'axios': 'axios',
|
|
46
|
-
* 'utils': './src/utils/index.ts'
|
|
47
|
-
* }
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
4
|
+
imports?: ModuleConfigImportMapping;
|
|
5
|
+
scopes?: Record<string, ModuleConfigImportMapping>;
|
|
50
6
|
exports?: ModuleConfigExportExports;
|
|
51
7
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
export type ModuleConfigExportExports = Array<string | Record<string, string | ModuleConfigExportObject>> | Record<string, string | ModuleConfigExportObject>;
|
|
58
|
-
/**
|
|
59
|
-
* Configuration object for individual module exports.
|
|
60
|
-
* Provides fine-grained control over module export behavior.
|
|
61
|
-
*/
|
|
62
|
-
export type ModuleConfigExportObject = {
|
|
63
|
-
/**
|
|
64
|
-
* Input file path, relative to project root directory.
|
|
65
|
-
*
|
|
66
|
-
* @example './src/utils/format'
|
|
67
|
-
*/
|
|
68
|
-
input?: string;
|
|
69
|
-
/**
|
|
70
|
-
* Environment-specific input file configuration.
|
|
71
|
-
* Supports client and server differentiated builds.
|
|
72
|
-
* Set to `false` to disable builds for specific environments.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* entryPoints: {
|
|
77
|
-
* client: './src/storage/indexedDB.ts',
|
|
78
|
-
* server: './src/storage/filesystem.ts'
|
|
79
|
-
* }
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
entryPoints?: Record<BuildEnvironment, string | false>;
|
|
83
|
-
/**
|
|
84
|
-
* Whether to rewrite import paths within modules.
|
|
85
|
-
*
|
|
86
|
-
* @default true
|
|
87
|
-
* @remarks Only needs to be false when exporting npm packages
|
|
88
|
-
*/
|
|
89
|
-
rewrite?: boolean;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Parsed and normalized module configuration.
|
|
93
|
-
* Contains resolved paths and processed configuration data.
|
|
94
|
-
*/
|
|
8
|
+
export type ModuleConfigImportMapping = Record<string, string | Record<BuildEnvironment, string>>;
|
|
9
|
+
export type ModuleConfigExportExports = ModuleConfigExportExport[];
|
|
10
|
+
export type ModuleConfigExportExport = string | ModuleConfigExportObject;
|
|
11
|
+
export type ModuleConfigExportObject = Record<string, ModuleConfigExportObjectValue>;
|
|
12
|
+
export type ModuleConfigExportObjectValue = string | Record<BuildEnvironment, string | boolean>;
|
|
95
13
|
export interface ParsedModuleConfig {
|
|
96
|
-
/** Module name */
|
|
97
14
|
name: string;
|
|
98
|
-
/** Module root directory path */
|
|
99
15
|
root: string;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
/** Module name */
|
|
106
|
-
name: string;
|
|
107
|
-
/** Original root path (relative or absolute) */
|
|
108
|
-
root: string;
|
|
109
|
-
/** Absolute path to client build directory */
|
|
110
|
-
client: string;
|
|
111
|
-
/** Absolute path to client manifest.json */
|
|
112
|
-
clientManifestJson: string;
|
|
113
|
-
/** Absolute path to server build directory */
|
|
114
|
-
server: string;
|
|
115
|
-
/** Absolute path to server manifest.json */
|
|
116
|
-
serverManifestJson: string;
|
|
117
|
-
}>;
|
|
118
|
-
/** Import mapping configuration (passed through as-is) */
|
|
119
|
-
imports: Record<string, string>;
|
|
120
|
-
/** Processed export configuration */
|
|
121
|
-
exports: ParsedModuleConfigExports;
|
|
16
|
+
links: Record<string, ParsedModuleConfigLink>;
|
|
17
|
+
environments: {
|
|
18
|
+
client: ParsedModuleConfigEnvironment;
|
|
19
|
+
server: ParsedModuleConfigEnvironment;
|
|
20
|
+
};
|
|
122
21
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Processed export configuration mapping.
|
|
125
|
-
* Maps export names to their resolved configuration objects.
|
|
126
|
-
*/
|
|
127
22
|
export type ParsedModuleConfigExports = Record<string, ParsedModuleConfigExport>;
|
|
128
|
-
/**
|
|
129
|
-
* Processed export configuration for a single module.
|
|
130
|
-
* Contains resolved input targets and processing flags.
|
|
131
|
-
*/
|
|
132
23
|
export interface ParsedModuleConfigExport {
|
|
133
|
-
/** Export name/identifier */
|
|
134
24
|
name: string;
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
25
|
+
file: string;
|
|
26
|
+
pkg: boolean;
|
|
27
|
+
}
|
|
28
|
+
export interface ParsedModuleConfigEnvironment {
|
|
29
|
+
imports: Record<string, string>;
|
|
30
|
+
exports: ParsedModuleConfigExports;
|
|
31
|
+
scopes: Record<string, Record<string, string>>;
|
|
32
|
+
}
|
|
33
|
+
export interface ParsedModuleConfigLink {
|
|
34
|
+
name: string;
|
|
35
|
+
root: string;
|
|
36
|
+
client: string;
|
|
37
|
+
clientManifestJson: string;
|
|
38
|
+
server: string;
|
|
39
|
+
serverManifestJson: string;
|
|
139
40
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Parse and normalize module configuration.
|
|
142
|
-
* Resolves paths, processes exports, and creates a standardized configuration object.
|
|
143
|
-
*
|
|
144
|
-
* @param name - Module name
|
|
145
|
-
* @param root - Module root directory path
|
|
146
|
-
* @param config - Raw module configuration (optional)
|
|
147
|
-
* @returns Parsed and normalized module configuration
|
|
148
|
-
*
|
|
149
|
-
* @example
|
|
150
|
-
* ```typescript
|
|
151
|
-
* const parsed = parseModuleConfig('my-app', '/path/to/app', {
|
|
152
|
-
* links: { 'shared-lib': '../shared-lib/dist' },
|
|
153
|
-
* imports: { 'axios': 'shared-lib/axios' },
|
|
154
|
-
* exports: ['npm:axios', 'root:src/utils/format.ts']
|
|
155
|
-
* });
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
41
|
export declare function parseModuleConfig(name: string, root: string, config?: ModuleConfig): ParsedModuleConfig;
|
|
42
|
+
export declare function getLinks(name: string, root: string, config: ModuleConfig): Record<string, ParsedModuleConfigLink>;
|
|
43
|
+
export declare function getEnvironmentImports(environment: BuildEnvironment, imports?: ModuleConfigImportMapping): Record<string, string>;
|
|
44
|
+
export declare function getEnvironmentScopes(environment: BuildEnvironment, scopes?: Record<string, ModuleConfigImportMapping>): Record<string, Record<string, string>>;
|
|
45
|
+
export declare function getEnvironments(config: ModuleConfig, env: BuildEnvironment, moduleName: string): ParsedModuleConfigEnvironment;
|
|
46
|
+
export declare function createDefaultExports(env: BuildEnvironment): ParsedModuleConfigExports;
|
|
47
|
+
export declare function processStringExport(exportString: string): ParsedModuleConfigExports;
|
|
48
|
+
export declare function processObjectExport(exportObject: ModuleConfigExportObject, env: BuildEnvironment): ParsedModuleConfigExports;
|
|
49
|
+
export declare function resolveExportFile(config: ModuleConfigExportObjectValue, env: BuildEnvironment, name: string): string;
|
|
50
|
+
export declare function processExportArray(exportArray: ModuleConfigExportExports, env: BuildEnvironment): ParsedModuleConfigExports;
|
|
51
|
+
export declare function getEnvironmentExports(config: ModuleConfig, env: BuildEnvironment): ParsedModuleConfigExports;
|
|
52
|
+
export declare function addPackageExportsToScopes(exports: ParsedModuleConfigExports, scopes: Record<string, Record<string, string>>, moduleName: string): Record<string, Record<string, string>>;
|
|
53
|
+
export declare function parsedExportValue(value: string): ParsedModuleConfigExport;
|
package/dist/module-config.mjs
CHANGED
|
@@ -4,17 +4,13 @@ export function parseModuleConfig(name, root, config = {}) {
|
|
|
4
4
|
name,
|
|
5
5
|
root,
|
|
6
6
|
links: getLinks(name, root, config),
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
environments: {
|
|
8
|
+
client: getEnvironments(config, "client", name),
|
|
9
|
+
server: getEnvironments(config, "server", name)
|
|
10
|
+
}
|
|
9
11
|
};
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
/** Prefix for npm package exports */
|
|
13
|
-
npm: "npm:",
|
|
14
|
-
/** Prefix for source file exports */
|
|
15
|
-
root: "root:"
|
|
16
|
-
};
|
|
17
|
-
function getLinks(name, root, config) {
|
|
13
|
+
export function getLinks(name, root, config) {
|
|
18
14
|
const result = {};
|
|
19
15
|
Object.entries({
|
|
20
16
|
[name]: path.resolve(root, "dist"),
|
|
@@ -35,61 +31,153 @@ function getLinks(name, root, config) {
|
|
|
35
31
|
});
|
|
36
32
|
return result;
|
|
37
33
|
}
|
|
38
|
-
function
|
|
34
|
+
export function getEnvironmentImports(environment, imports = {}) {
|
|
39
35
|
const result = {};
|
|
40
|
-
const
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"src/entry.server": {
|
|
48
|
-
entryPoints: {
|
|
49
|
-
client: false,
|
|
50
|
-
server: "./src/entry.server"
|
|
36
|
+
for (const [key, value] of Object.entries(imports)) {
|
|
37
|
+
if (typeof value === "string") {
|
|
38
|
+
result[key] = value;
|
|
39
|
+
} else {
|
|
40
|
+
const environmentValue = value[environment];
|
|
41
|
+
if (environmentValue !== void 0) {
|
|
42
|
+
result[key] = environmentValue;
|
|
51
43
|
}
|
|
52
44
|
}
|
|
45
|
+
}
|
|
46
|
+
return result;
|
|
47
|
+
}
|
|
48
|
+
export function getEnvironmentScopes(environment, scopes = {}) {
|
|
49
|
+
const result = {};
|
|
50
|
+
for (const [scopeName, scopeImports] of Object.entries(scopes)) {
|
|
51
|
+
result[scopeName] = getEnvironmentImports(environment, scopeImports);
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
}
|
|
55
|
+
export function getEnvironments(config, env, moduleName) {
|
|
56
|
+
const imports = getEnvironmentImports(env, config.imports);
|
|
57
|
+
const exports = getEnvironmentExports(config, env);
|
|
58
|
+
const scopes = getEnvironmentScopes(env, config.scopes);
|
|
59
|
+
addPackageExportsToScopes(exports, scopes, moduleName);
|
|
60
|
+
return {
|
|
61
|
+
imports,
|
|
62
|
+
exports,
|
|
63
|
+
scopes
|
|
53
64
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
} else {
|
|
70
|
-
console.error(`Invalid module export: ${item}`);
|
|
65
|
+
}
|
|
66
|
+
export function createDefaultExports(env) {
|
|
67
|
+
switch (env) {
|
|
68
|
+
case "client":
|
|
69
|
+
return {
|
|
70
|
+
"src/entry.client": {
|
|
71
|
+
name: "src/entry.client",
|
|
72
|
+
file: "./src/entry.client",
|
|
73
|
+
pkg: false
|
|
74
|
+
},
|
|
75
|
+
"src/entry.server": {
|
|
76
|
+
name: "src/entry.server",
|
|
77
|
+
file: "",
|
|
78
|
+
pkg: false
|
|
71
79
|
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
80
|
+
};
|
|
81
|
+
case "server":
|
|
82
|
+
return {
|
|
83
|
+
"src/entry.client": {
|
|
84
|
+
name: "src/entry.client",
|
|
85
|
+
file: "",
|
|
86
|
+
pkg: false
|
|
87
|
+
},
|
|
88
|
+
"src/entry.server": {
|
|
89
|
+
name: "src/entry.server",
|
|
90
|
+
file: "./src/entry.server",
|
|
91
|
+
pkg: false
|
|
92
|
+
}
|
|
93
|
+
};
|
|
78
94
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
}
|
|
96
|
+
export function processStringExport(exportString) {
|
|
97
|
+
const parsedValue = parsedExportValue(exportString);
|
|
98
|
+
return { [parsedValue.name]: parsedValue };
|
|
99
|
+
}
|
|
100
|
+
export function processObjectExport(exportObject, env) {
|
|
101
|
+
const exports = {};
|
|
102
|
+
Object.keys(exportObject).forEach((name) => {
|
|
103
|
+
const config = exportObject[name];
|
|
104
|
+
if (typeof config === "string") {
|
|
105
|
+
const parsedValue2 = parsedExportValue(config);
|
|
106
|
+
exports[name] = { ...parsedValue2, name };
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const filePath = resolveExportFile(config, env, name);
|
|
110
|
+
const parsedValue = parsedExportValue(filePath);
|
|
111
|
+
exports[name] = { ...parsedValue, name };
|
|
112
|
+
});
|
|
113
|
+
return exports;
|
|
114
|
+
}
|
|
115
|
+
export function resolveExportFile(config, env, name) {
|
|
116
|
+
if (typeof config === "string") {
|
|
117
|
+
return config;
|
|
118
|
+
}
|
|
119
|
+
const value = config[env];
|
|
120
|
+
if (typeof value === "boolean") {
|
|
121
|
+
return value === true ? name : "";
|
|
122
|
+
} else if (typeof value === "string") {
|
|
123
|
+
return value || name;
|
|
124
|
+
}
|
|
125
|
+
return name;
|
|
126
|
+
}
|
|
127
|
+
export function processExportArray(exportArray, env) {
|
|
128
|
+
const exports = {};
|
|
129
|
+
exportArray.forEach((item) => {
|
|
130
|
+
if (typeof item === "string") {
|
|
131
|
+
const itemExports = processStringExport(item);
|
|
132
|
+
Object.assign(exports, itemExports);
|
|
133
|
+
} else {
|
|
134
|
+
const itemExports = processObjectExport(item, env);
|
|
135
|
+
Object.assign(exports, itemExports);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
return exports;
|
|
139
|
+
}
|
|
140
|
+
export function getEnvironmentExports(config, env) {
|
|
141
|
+
const exports = createDefaultExports(env);
|
|
142
|
+
if (config.exports) {
|
|
143
|
+
const userExports = processExportArray(config.exports, env);
|
|
144
|
+
Object.assign(exports, userExports);
|
|
145
|
+
}
|
|
146
|
+
return exports;
|
|
147
|
+
}
|
|
148
|
+
export function addPackageExportsToScopes(exports, scopes, moduleName) {
|
|
149
|
+
Object.entries(exports).forEach(([exportName, exportConfig]) => {
|
|
150
|
+
if (exportConfig.pkg) {
|
|
151
|
+
if (!scopes[""]) {
|
|
152
|
+
scopes[""] = {};
|
|
91
153
|
}
|
|
154
|
+
scopes[""][exportName] = moduleName + "/" + exportName;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
return scopes;
|
|
158
|
+
}
|
|
159
|
+
export function parsedExportValue(value) {
|
|
160
|
+
const FILE_EXT_REGEX = /\.(js|mjs|cjs|jsx|mjsx|cjsx|ts|mts|cts|tsx|mtsx|ctsx)$/i;
|
|
161
|
+
if (value.startsWith("pkg:")) {
|
|
162
|
+
const item = value.substring("pkg:".length);
|
|
163
|
+
return {
|
|
164
|
+
name: item,
|
|
165
|
+
pkg: true,
|
|
166
|
+
file: item
|
|
167
|
+
};
|
|
168
|
+
} else if (value.startsWith("root:")) {
|
|
169
|
+
const item = value.substring("root:".length);
|
|
170
|
+
const name = item.replace(FILE_EXT_REGEX, "");
|
|
171
|
+
return {
|
|
172
|
+
name,
|
|
173
|
+
pkg: false,
|
|
174
|
+
file: "./" + item
|
|
175
|
+
};
|
|
176
|
+
} else {
|
|
177
|
+
return {
|
|
178
|
+
name: value,
|
|
179
|
+
pkg: false,
|
|
180
|
+
file: value
|
|
92
181
|
};
|
|
93
182
|
}
|
|
94
|
-
return result;
|
|
95
183
|
}
|