@utoo/pack 0.0.1-alpha.16 → 0.0.1-alpha.18
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/cjs/binding.d.ts +9 -7
- package/cjs/types.d.ts +1 -0
- package/cjs/webpackCompat.js +117 -26
- package/esm/binding.d.ts +9 -7
- package/esm/types.d.ts +1 -0
- package/esm/webpackCompat.js +117 -26
- package/package.json +8 -8
package/cjs/binding.d.ts
CHANGED
|
@@ -136,7 +136,7 @@ export interface NapiEntrypoints {
|
|
|
136
136
|
}
|
|
137
137
|
export declare function projectWriteAllEntrypointsToDisk(project: { __napiType: "Project" }): Promise<TurbopackResult>
|
|
138
138
|
export declare function projectEntrypointsSubscribe(project: { __napiType: "Project" }, func: (...args: any[]) => any): { __napiType: "RootTask" }
|
|
139
|
-
export declare function projectHmrEvents(project: { __napiType: "Project" }, identifier:
|
|
139
|
+
export declare function projectHmrEvents(project: { __napiType: "Project" }, identifier: RcStr, func: (...args: any[]) => any): { __napiType: "RootTask" }
|
|
140
140
|
export interface HmrIdentifiers {
|
|
141
141
|
identifiers: Array<string>
|
|
142
142
|
}
|
|
@@ -166,16 +166,18 @@ export declare function projectUpdateInfoSubscribe(project: { __napiType: "Proje
|
|
|
166
166
|
export interface StackFrame {
|
|
167
167
|
isServer: boolean
|
|
168
168
|
isInternal?: boolean
|
|
169
|
-
originalFile?:
|
|
170
|
-
file:
|
|
169
|
+
originalFile?: RcStr
|
|
170
|
+
file: RcStr
|
|
171
|
+
/** 1-indexed, unlike source map tokens */
|
|
171
172
|
line?: number
|
|
173
|
+
/** 1-indexed, unlike source map tokens */
|
|
172
174
|
column?: number
|
|
173
|
-
methodName?:
|
|
175
|
+
methodName?: RcStr
|
|
174
176
|
}
|
|
175
177
|
export declare function projectTraceSource(project: { __napiType: "Project" }, frame: StackFrame, currentDirectoryFileUrl: string): Promise<StackFrame | null>
|
|
176
178
|
export declare function projectGetSourceForAsset(project: { __napiType: "Project" }, filePath: string): Promise<string | null>
|
|
177
|
-
export declare function projectGetSourceMap(project: { __napiType: "Project" }, filePath:
|
|
178
|
-
export declare function projectGetSourceMapSync(project: { __napiType: "Project" }, filePath:
|
|
179
|
+
export declare function projectGetSourceMap(project: { __napiType: "Project" }, filePath: RcStr): Promise<string | null>
|
|
180
|
+
export declare function projectGetSourceMapSync(project: { __napiType: "Project" }, filePath: RcStr): string | null
|
|
179
181
|
export declare function rootTaskDispose(rootTask: { __napiType: "RootTask" }): void
|
|
180
182
|
export interface NapiIssue {
|
|
181
183
|
severity: string
|
|
@@ -186,7 +188,7 @@ export interface NapiIssue {
|
|
|
186
188
|
detail?: any
|
|
187
189
|
source?: NapiIssueSource
|
|
188
190
|
documentationLink: string
|
|
189
|
-
|
|
191
|
+
importTraces: any
|
|
190
192
|
}
|
|
191
193
|
export interface NapiIssueSource {
|
|
192
194
|
source: NapiSource
|
package/cjs/types.d.ts
CHANGED
package/cjs/webpackCompat.js
CHANGED
|
@@ -94,44 +94,135 @@ compatDefine.pluginName = "DefinePlugin";
|
|
|
94
94
|
function compatDefine(maybeWebpackPluginInstance) {
|
|
95
95
|
return maybeWebpackPluginInstance === null || maybeWebpackPluginInstance === void 0 ? void 0 : maybeWebpackPluginInstance.definitions;
|
|
96
96
|
}
|
|
97
|
-
function compatExternals(
|
|
97
|
+
function compatExternals(webpackExternals) {
|
|
98
|
+
if (!webpackExternals) {
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
98
101
|
let externals = {};
|
|
99
|
-
switch (typeof
|
|
100
|
-
case "string":
|
|
101
|
-
|
|
102
|
+
switch (typeof webpackExternals) {
|
|
103
|
+
case "string": {
|
|
104
|
+
// Single string external: "lodash" -> { "lodash": "lodash" }
|
|
105
|
+
externals[webpackExternals] = webpackExternals;
|
|
102
106
|
break;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
case "string":
|
|
111
|
-
externals[k] = k;
|
|
112
|
-
break;
|
|
113
|
-
default:
|
|
114
|
-
throw "non string external item not supported yet";
|
|
107
|
+
}
|
|
108
|
+
case "object": {
|
|
109
|
+
if (Array.isArray(webpackExternals)) {
|
|
110
|
+
// Array of externals: ["lodash", "react"] -> { "lodash": "lodash", "react": "react" }
|
|
111
|
+
externals = webpackExternals.reduce((acc, external) => {
|
|
112
|
+
if (typeof external === "string") {
|
|
113
|
+
acc[external] = external;
|
|
115
114
|
}
|
|
116
|
-
|
|
115
|
+
else if (typeof external === "object" && external !== null) {
|
|
116
|
+
Object.assign(acc, compatExternals(external));
|
|
117
|
+
}
|
|
118
|
+
return acc;
|
|
119
|
+
}, {});
|
|
120
|
+
}
|
|
121
|
+
else if (webpackExternals instanceof RegExp) {
|
|
122
|
+
throw "regex external not supported yet";
|
|
117
123
|
}
|
|
118
124
|
else {
|
|
119
|
-
if ("byLayer" in
|
|
125
|
+
if ("byLayer" in webpackExternals) {
|
|
120
126
|
throw "by layer external item not supported yet";
|
|
121
127
|
}
|
|
122
|
-
Object.entries(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
Object.entries(webpackExternals).forEach(([key, value]) => {
|
|
129
|
+
if (typeof value === "string") {
|
|
130
|
+
// Check if it's a script type with shorthand syntax: "global@https://example.com/script.js"
|
|
131
|
+
if (value.includes("@") &&
|
|
132
|
+
(value.startsWith("script ") || value.includes("://"))) {
|
|
133
|
+
const match = value.match(/^(?:script\s+)?(.+?)@(.+)$/);
|
|
134
|
+
if (match) {
|
|
135
|
+
const [, globalName, scriptUrl] = match;
|
|
136
|
+
// Use utoo-pack string format: "script globalName@url"
|
|
137
|
+
externals[key] = `script ${globalName}@${scriptUrl}`;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
externals[key] = value;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
// Simple string mapping: { "react": "React" }
|
|
145
|
+
externals[key] = value;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else if (Array.isArray(value)) {
|
|
149
|
+
// Array format handling
|
|
150
|
+
if (value.length >= 2) {
|
|
151
|
+
const [first, second] = value;
|
|
152
|
+
// Check if it's a script type array: ["https://example.com/script.js", "GlobalName"]
|
|
153
|
+
if (typeof first === "string" &&
|
|
154
|
+
first.includes("://") &&
|
|
155
|
+
typeof second === "string") {
|
|
156
|
+
// Use utoo-pack object format for script
|
|
157
|
+
externals[key] = {
|
|
158
|
+
root: second,
|
|
159
|
+
type: "script",
|
|
160
|
+
script: first,
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
else if (typeof first === "string" &&
|
|
164
|
+
typeof second === "string") {
|
|
165
|
+
// Handle type prefix formats
|
|
166
|
+
if (first.startsWith("commonjs")) {
|
|
167
|
+
externals[key] = `commonjs ${second}`;
|
|
168
|
+
}
|
|
169
|
+
else if (first === "module") {
|
|
170
|
+
externals[key] = `esm ${second}`;
|
|
171
|
+
}
|
|
172
|
+
else if (first === "var" ||
|
|
173
|
+
first === "global" ||
|
|
174
|
+
first === "window") {
|
|
175
|
+
externals[key] = second;
|
|
176
|
+
}
|
|
177
|
+
else if (first === "script") {
|
|
178
|
+
// Script type without URL in array format - treat as regular script prefix
|
|
179
|
+
externals[key] = `script ${second}`;
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
externals[key] = `${first} ${second}`;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
externals[key] = value[0] || key;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
externals[key] = value[0] || key;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
else if (typeof value === "object" && value !== null) {
|
|
194
|
+
// Object format: handle complex configurations
|
|
195
|
+
if ("root" in value || "commonjs" in value || "amd" in value) {
|
|
196
|
+
// Standard webpack externals object format
|
|
197
|
+
if (value.commonjs) {
|
|
198
|
+
externals[key] = `commonjs ${value.commonjs}`;
|
|
199
|
+
}
|
|
200
|
+
else if (value.root) {
|
|
201
|
+
externals[key] = value.root;
|
|
202
|
+
}
|
|
203
|
+
else if (value.amd) {
|
|
204
|
+
externals[key] = value.amd;
|
|
205
|
+
}
|
|
206
|
+
else {
|
|
207
|
+
externals[key] = key;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
// Treat as utoo-pack specific configuration (might already be in correct format)
|
|
212
|
+
externals[key] = value;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
// Fallback to key name
|
|
217
|
+
externals[key] = key;
|
|
129
218
|
}
|
|
130
219
|
});
|
|
131
220
|
}
|
|
132
221
|
break;
|
|
133
|
-
|
|
222
|
+
}
|
|
223
|
+
case "function": {
|
|
134
224
|
throw "functional external not supported yet";
|
|
225
|
+
}
|
|
135
226
|
default:
|
|
136
227
|
break;
|
|
137
228
|
}
|
package/esm/binding.d.ts
CHANGED
|
@@ -136,7 +136,7 @@ export interface NapiEntrypoints {
|
|
|
136
136
|
}
|
|
137
137
|
export declare function projectWriteAllEntrypointsToDisk(project: { __napiType: "Project" }): Promise<TurbopackResult>
|
|
138
138
|
export declare function projectEntrypointsSubscribe(project: { __napiType: "Project" }, func: (...args: any[]) => any): { __napiType: "RootTask" }
|
|
139
|
-
export declare function projectHmrEvents(project: { __napiType: "Project" }, identifier:
|
|
139
|
+
export declare function projectHmrEvents(project: { __napiType: "Project" }, identifier: RcStr, func: (...args: any[]) => any): { __napiType: "RootTask" }
|
|
140
140
|
export interface HmrIdentifiers {
|
|
141
141
|
identifiers: Array<string>
|
|
142
142
|
}
|
|
@@ -166,16 +166,18 @@ export declare function projectUpdateInfoSubscribe(project: { __napiType: "Proje
|
|
|
166
166
|
export interface StackFrame {
|
|
167
167
|
isServer: boolean
|
|
168
168
|
isInternal?: boolean
|
|
169
|
-
originalFile?:
|
|
170
|
-
file:
|
|
169
|
+
originalFile?: RcStr
|
|
170
|
+
file: RcStr
|
|
171
|
+
/** 1-indexed, unlike source map tokens */
|
|
171
172
|
line?: number
|
|
173
|
+
/** 1-indexed, unlike source map tokens */
|
|
172
174
|
column?: number
|
|
173
|
-
methodName?:
|
|
175
|
+
methodName?: RcStr
|
|
174
176
|
}
|
|
175
177
|
export declare function projectTraceSource(project: { __napiType: "Project" }, frame: StackFrame, currentDirectoryFileUrl: string): Promise<StackFrame | null>
|
|
176
178
|
export declare function projectGetSourceForAsset(project: { __napiType: "Project" }, filePath: string): Promise<string | null>
|
|
177
|
-
export declare function projectGetSourceMap(project: { __napiType: "Project" }, filePath:
|
|
178
|
-
export declare function projectGetSourceMapSync(project: { __napiType: "Project" }, filePath:
|
|
179
|
+
export declare function projectGetSourceMap(project: { __napiType: "Project" }, filePath: RcStr): Promise<string | null>
|
|
180
|
+
export declare function projectGetSourceMapSync(project: { __napiType: "Project" }, filePath: RcStr): string | null
|
|
179
181
|
export declare function rootTaskDispose(rootTask: { __napiType: "RootTask" }): void
|
|
180
182
|
export interface NapiIssue {
|
|
181
183
|
severity: string
|
|
@@ -186,7 +188,7 @@ export interface NapiIssue {
|
|
|
186
188
|
detail?: any
|
|
187
189
|
source?: NapiIssueSource
|
|
188
190
|
documentationLink: string
|
|
189
|
-
|
|
191
|
+
importTraces: any
|
|
190
192
|
}
|
|
191
193
|
export interface NapiIssueSource {
|
|
192
194
|
source: NapiSource
|
package/esm/types.d.ts
CHANGED
package/esm/webpackCompat.js
CHANGED
|
@@ -91,44 +91,135 @@ compatDefine.pluginName = "DefinePlugin";
|
|
|
91
91
|
function compatDefine(maybeWebpackPluginInstance) {
|
|
92
92
|
return maybeWebpackPluginInstance === null || maybeWebpackPluginInstance === void 0 ? void 0 : maybeWebpackPluginInstance.definitions;
|
|
93
93
|
}
|
|
94
|
-
function compatExternals(
|
|
94
|
+
function compatExternals(webpackExternals) {
|
|
95
|
+
if (!webpackExternals) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
95
98
|
let externals = {};
|
|
96
|
-
switch (typeof
|
|
97
|
-
case "string":
|
|
98
|
-
|
|
99
|
+
switch (typeof webpackExternals) {
|
|
100
|
+
case "string": {
|
|
101
|
+
// Single string external: "lodash" -> { "lodash": "lodash" }
|
|
102
|
+
externals[webpackExternals] = webpackExternals;
|
|
99
103
|
break;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
case "string":
|
|
108
|
-
externals[k] = k;
|
|
109
|
-
break;
|
|
110
|
-
default:
|
|
111
|
-
throw "non string external item not supported yet";
|
|
104
|
+
}
|
|
105
|
+
case "object": {
|
|
106
|
+
if (Array.isArray(webpackExternals)) {
|
|
107
|
+
// Array of externals: ["lodash", "react"] -> { "lodash": "lodash", "react": "react" }
|
|
108
|
+
externals = webpackExternals.reduce((acc, external) => {
|
|
109
|
+
if (typeof external === "string") {
|
|
110
|
+
acc[external] = external;
|
|
112
111
|
}
|
|
113
|
-
|
|
112
|
+
else if (typeof external === "object" && external !== null) {
|
|
113
|
+
Object.assign(acc, compatExternals(external));
|
|
114
|
+
}
|
|
115
|
+
return acc;
|
|
116
|
+
}, {});
|
|
117
|
+
}
|
|
118
|
+
else if (webpackExternals instanceof RegExp) {
|
|
119
|
+
throw "regex external not supported yet";
|
|
114
120
|
}
|
|
115
121
|
else {
|
|
116
|
-
if ("byLayer" in
|
|
122
|
+
if ("byLayer" in webpackExternals) {
|
|
117
123
|
throw "by layer external item not supported yet";
|
|
118
124
|
}
|
|
119
|
-
Object.entries(
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
125
|
+
Object.entries(webpackExternals).forEach(([key, value]) => {
|
|
126
|
+
if (typeof value === "string") {
|
|
127
|
+
// Check if it's a script type with shorthand syntax: "global@https://example.com/script.js"
|
|
128
|
+
if (value.includes("@") &&
|
|
129
|
+
(value.startsWith("script ") || value.includes("://"))) {
|
|
130
|
+
const match = value.match(/^(?:script\s+)?(.+?)@(.+)$/);
|
|
131
|
+
if (match) {
|
|
132
|
+
const [, globalName, scriptUrl] = match;
|
|
133
|
+
// Use utoo-pack string format: "script globalName@url"
|
|
134
|
+
externals[key] = `script ${globalName}@${scriptUrl}`;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
externals[key] = value;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
// Simple string mapping: { "react": "React" }
|
|
142
|
+
externals[key] = value;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
else if (Array.isArray(value)) {
|
|
146
|
+
// Array format handling
|
|
147
|
+
if (value.length >= 2) {
|
|
148
|
+
const [first, second] = value;
|
|
149
|
+
// Check if it's a script type array: ["https://example.com/script.js", "GlobalName"]
|
|
150
|
+
if (typeof first === "string" &&
|
|
151
|
+
first.includes("://") &&
|
|
152
|
+
typeof second === "string") {
|
|
153
|
+
// Use utoo-pack object format for script
|
|
154
|
+
externals[key] = {
|
|
155
|
+
root: second,
|
|
156
|
+
type: "script",
|
|
157
|
+
script: first,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
else if (typeof first === "string" &&
|
|
161
|
+
typeof second === "string") {
|
|
162
|
+
// Handle type prefix formats
|
|
163
|
+
if (first.startsWith("commonjs")) {
|
|
164
|
+
externals[key] = `commonjs ${second}`;
|
|
165
|
+
}
|
|
166
|
+
else if (first === "module") {
|
|
167
|
+
externals[key] = `esm ${second}`;
|
|
168
|
+
}
|
|
169
|
+
else if (first === "var" ||
|
|
170
|
+
first === "global" ||
|
|
171
|
+
first === "window") {
|
|
172
|
+
externals[key] = second;
|
|
173
|
+
}
|
|
174
|
+
else if (first === "script") {
|
|
175
|
+
// Script type without URL in array format - treat as regular script prefix
|
|
176
|
+
externals[key] = `script ${second}`;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
externals[key] = `${first} ${second}`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else {
|
|
183
|
+
externals[key] = value[0] || key;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
externals[key] = value[0] || key;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
else if (typeof value === "object" && value !== null) {
|
|
191
|
+
// Object format: handle complex configurations
|
|
192
|
+
if ("root" in value || "commonjs" in value || "amd" in value) {
|
|
193
|
+
// Standard webpack externals object format
|
|
194
|
+
if (value.commonjs) {
|
|
195
|
+
externals[key] = `commonjs ${value.commonjs}`;
|
|
196
|
+
}
|
|
197
|
+
else if (value.root) {
|
|
198
|
+
externals[key] = value.root;
|
|
199
|
+
}
|
|
200
|
+
else if (value.amd) {
|
|
201
|
+
externals[key] = value.amd;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
externals[key] = key;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
// Treat as utoo-pack specific configuration (might already be in correct format)
|
|
209
|
+
externals[key] = value;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
// Fallback to key name
|
|
214
|
+
externals[key] = key;
|
|
126
215
|
}
|
|
127
216
|
});
|
|
128
217
|
}
|
|
129
218
|
break;
|
|
130
|
-
|
|
219
|
+
}
|
|
220
|
+
case "function": {
|
|
131
221
|
throw "functional external not supported yet";
|
|
222
|
+
}
|
|
132
223
|
default:
|
|
133
224
|
break;
|
|
134
225
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@utoo/pack",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.18",
|
|
4
4
|
"main": "cjs/index.js",
|
|
5
5
|
"module": "esm/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -81,12 +81,12 @@
|
|
|
81
81
|
},
|
|
82
82
|
"repository": "git@github.com:umijs/mako.git",
|
|
83
83
|
"optionalDependencies": {
|
|
84
|
-
"@utoo/pack-darwin-arm64": "0.0.1-alpha.
|
|
85
|
-
"@utoo/pack-darwin-x64": "0.0.1-alpha.
|
|
86
|
-
"@utoo/pack-linux-arm64-gnu": "0.0.1-alpha.
|
|
87
|
-
"@utoo/pack-linux-arm64-musl": "0.0.1-alpha.
|
|
88
|
-
"@utoo/pack-linux-x64-gnu": "0.0.1-alpha.
|
|
89
|
-
"@utoo/pack-linux-x64-musl": "0.0.1-alpha.
|
|
90
|
-
"@utoo/pack-win32-x64-msvc": "0.0.1-alpha.
|
|
84
|
+
"@utoo/pack-darwin-arm64": "0.0.1-alpha.18",
|
|
85
|
+
"@utoo/pack-darwin-x64": "0.0.1-alpha.18",
|
|
86
|
+
"@utoo/pack-linux-arm64-gnu": "0.0.1-alpha.18",
|
|
87
|
+
"@utoo/pack-linux-arm64-musl": "0.0.1-alpha.18",
|
|
88
|
+
"@utoo/pack-linux-x64-gnu": "0.0.1-alpha.18",
|
|
89
|
+
"@utoo/pack-linux-x64-musl": "0.0.1-alpha.18",
|
|
90
|
+
"@utoo/pack-win32-x64-msvc": "0.0.1-alpha.18"
|
|
91
91
|
}
|
|
92
92
|
}
|