@utoo/pack 0.0.1-alpha.14 → 0.0.1-alpha.16
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 +100 -153
- package/cjs/build.d.ts +3 -1
- package/cjs/build.js +18 -11
- package/cjs/dev.d.ts +3 -1
- package/cjs/dev.js +9 -2
- package/cjs/hmr.js +3 -3
- package/cjs/index.d.ts +14 -2
- package/cjs/index.js +4 -2
- package/cjs/project.d.ts +1 -1
- package/cjs/project.js +0 -2
- package/cjs/types.d.ts +7 -7
- package/cjs/webpackCompat.d.ts +6 -0
- package/cjs/webpackCompat.js +250 -0
- package/esm/binding.d.ts +100 -153
- package/esm/build.d.ts +3 -1
- package/esm/build.js +18 -11
- package/esm/dev.d.ts +3 -1
- package/esm/dev.js +9 -2
- package/esm/hmr.js +3 -3
- package/esm/index.d.ts +14 -2
- package/esm/index.js +6 -2
- package/esm/project.d.ts +1 -1
- package/esm/project.js +0 -2
- package/esm/types.d.ts +7 -7
- package/esm/webpackCompat.d.ts +6 -0
- package/esm/webpackCompat.js +247 -0
- package/package.json +11 -9
package/cjs/binding.d.ts
CHANGED
|
@@ -4,78 +4,70 @@
|
|
|
4
4
|
/* auto-generated by NAPI-RS */
|
|
5
5
|
|
|
6
6
|
export declare class ExternalObject<T> {
|
|
7
|
-
readonly
|
|
8
|
-
readonly
|
|
9
|
-
[K: symbol]: T
|
|
10
|
-
}
|
|
7
|
+
readonly '': {
|
|
8
|
+
readonly '': unique symbol
|
|
9
|
+
[K: symbol]: T
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
12
|
export interface TransformOutput {
|
|
13
|
-
code: string
|
|
14
|
-
map?: string
|
|
15
|
-
output?: string
|
|
16
|
-
diagnostics: Array<string
|
|
13
|
+
code: string
|
|
14
|
+
map?: string
|
|
15
|
+
output?: string
|
|
16
|
+
diagnostics: Array<string>
|
|
17
|
+
}
|
|
18
|
+
export interface NapiEndpointConfig {
|
|
19
|
+
|
|
17
20
|
}
|
|
18
|
-
|
|
19
|
-
export interface NapiEndpointConfig {}
|
|
20
21
|
export interface NapiServerPath {
|
|
21
|
-
path: string
|
|
22
|
-
contentHash: string
|
|
22
|
+
path: string
|
|
23
|
+
contentHash: string
|
|
23
24
|
}
|
|
24
25
|
export interface NapiWrittenEndpoint {
|
|
25
|
-
type: string
|
|
26
|
-
entryPath?: string
|
|
27
|
-
clientPaths: Array<string
|
|
28
|
-
serverPaths: Array<NapiServerPath
|
|
29
|
-
config: NapiEndpointConfig
|
|
30
|
-
}
|
|
31
|
-
export declare function endpointWriteToDisk(endpoint: {
|
|
32
|
-
|
|
33
|
-
}):
|
|
34
|
-
export declare function endpointServerChangedSubscribe(
|
|
35
|
-
endpoint: { __napiType: "Endpoint" },
|
|
36
|
-
issues: boolean,
|
|
37
|
-
func: (...args: any[]) => any,
|
|
38
|
-
): { __napiType: "RootTask" };
|
|
39
|
-
export declare function endpointClientChangedSubscribe(
|
|
40
|
-
endpoint: { __napiType: "Endpoint" },
|
|
41
|
-
func: (...args: any[]) => any,
|
|
42
|
-
): { __napiType: "RootTask" };
|
|
26
|
+
type: string
|
|
27
|
+
entryPath?: string
|
|
28
|
+
clientPaths: Array<string>
|
|
29
|
+
serverPaths: Array<NapiServerPath>
|
|
30
|
+
config: NapiEndpointConfig
|
|
31
|
+
}
|
|
32
|
+
export declare function endpointWriteToDisk(endpoint: { __napiType: "Endpoint" }): Promise<TurbopackResult>
|
|
33
|
+
export declare function endpointServerChangedSubscribe(endpoint: { __napiType: "Endpoint" }, issues: boolean, func: (...args: any[]) => any): { __napiType: "RootTask" }
|
|
34
|
+
export declare function endpointClientChangedSubscribe(endpoint: { __napiType: "Endpoint" }, func: (...args: any[]) => any): { __napiType: "RootTask" }
|
|
43
35
|
export interface NapiEnvVar {
|
|
44
|
-
name: string
|
|
45
|
-
value: string
|
|
36
|
+
name: string
|
|
37
|
+
value: string
|
|
46
38
|
}
|
|
47
39
|
export interface NapiWatchOptions {
|
|
48
40
|
/** Whether to watch the filesystem for file changes. */
|
|
49
|
-
enable: boolean
|
|
41
|
+
enable: boolean
|
|
50
42
|
/**
|
|
51
43
|
* Enable polling at a certain interval if the native file watching doesn't work (e.g.
|
|
52
44
|
* docker).
|
|
53
45
|
*/
|
|
54
|
-
pollIntervalMs?: number
|
|
46
|
+
pollIntervalMs?: number
|
|
55
47
|
}
|
|
56
48
|
export interface NapiProjectOptions {
|
|
57
49
|
/**
|
|
58
50
|
* A root path from which all files must be nested under. Trying to access
|
|
59
51
|
* a file outside this root will fail. Think of this as a chroot.
|
|
60
52
|
*/
|
|
61
|
-
rootPath: string
|
|
53
|
+
rootPath: string
|
|
62
54
|
/** A path inside the root_path which contains the app/pages directories. */
|
|
63
|
-
projectPath: string
|
|
55
|
+
projectPath: string
|
|
64
56
|
/** Filesystem watcher options. */
|
|
65
|
-
watch: NapiWatchOptions
|
|
57
|
+
watch: NapiWatchOptions
|
|
66
58
|
/** The contents of config.js, serialized to JSON. */
|
|
67
|
-
config: string
|
|
59
|
+
config: string
|
|
68
60
|
/** A map of environment variables to use when compiling code. */
|
|
69
|
-
processEnv: Array<NapiEnvVar
|
|
61
|
+
processEnv: Array<NapiEnvVar>
|
|
70
62
|
/**
|
|
71
63
|
* A map of environment variables which should get injected at compile
|
|
72
64
|
* time.
|
|
73
65
|
*/
|
|
74
|
-
|
|
66
|
+
defineEnv: NapiDefineEnv
|
|
75
67
|
/** The mode in which Next.js is running. */
|
|
76
|
-
dev: boolean
|
|
68
|
+
dev: boolean
|
|
77
69
|
/** The build id. */
|
|
78
|
-
buildId: string
|
|
70
|
+
buildId: string
|
|
79
71
|
}
|
|
80
72
|
/** [NapiProjectOptions] with all fields optional. */
|
|
81
73
|
export interface NapiPartialProjectOptions {
|
|
@@ -83,61 +75,53 @@ export interface NapiPartialProjectOptions {
|
|
|
83
75
|
* A root path from which all files must be nested under. Trying to access
|
|
84
76
|
* a file outside this root will fail. Think of this as a chroot.
|
|
85
77
|
*/
|
|
86
|
-
rootPath?: string
|
|
78
|
+
rootPath?: string
|
|
87
79
|
/** A path inside the root_path which contains the app/pages directories. */
|
|
88
|
-
projectPath?: string
|
|
80
|
+
projectPath?: string
|
|
89
81
|
/** Filesystem watcher options. */
|
|
90
|
-
watch?: NapiWatchOptions
|
|
82
|
+
watch?: NapiWatchOptions
|
|
91
83
|
/** The contents of config.js, serialized to JSON. */
|
|
92
|
-
config?: string
|
|
84
|
+
config?: string
|
|
93
85
|
/** A map of environment variables to use when compiling code. */
|
|
94
|
-
processEnv?: Array<NapiEnvVar
|
|
86
|
+
processEnv?: Array<NapiEnvVar>
|
|
95
87
|
/**
|
|
96
88
|
* A map of environment variables which should get injected at compile
|
|
97
89
|
* time.
|
|
98
90
|
*/
|
|
99
|
-
|
|
91
|
+
defineEnv?: NapiDefineEnv
|
|
100
92
|
/** The mode in which Next.js is running. */
|
|
101
|
-
dev?: boolean
|
|
93
|
+
dev?: boolean
|
|
102
94
|
/** The build id. */
|
|
103
|
-
buildId?: string
|
|
95
|
+
buildId?: string
|
|
104
96
|
/**
|
|
105
97
|
* When the code is minified, this opts out of the default mangling of
|
|
106
98
|
* local names for variables, functions etc., which can be useful for
|
|
107
99
|
* debugging/profiling purposes.
|
|
108
100
|
*/
|
|
109
|
-
noMangling?: boolean
|
|
101
|
+
noMangling?: boolean
|
|
110
102
|
}
|
|
111
103
|
export interface NapiDefineEnv {
|
|
112
|
-
client: Array<NapiEnvVar
|
|
113
|
-
edge: Array<NapiEnvVar
|
|
114
|
-
nodejs: Array<NapiEnvVar
|
|
104
|
+
client: Array<NapiEnvVar>
|
|
105
|
+
edge: Array<NapiEnvVar>
|
|
106
|
+
nodejs: Array<NapiEnvVar>
|
|
115
107
|
}
|
|
116
108
|
export interface NapiTurboEngineOptions {
|
|
117
109
|
/** Use the new backend with persistent caching enabled. */
|
|
118
|
-
persistentCaching?: boolean
|
|
110
|
+
persistentCaching?: boolean
|
|
119
111
|
/** An upper bound of memory that turbopack will attempt to stay under. */
|
|
120
|
-
memoryLimit?: number
|
|
112
|
+
memoryLimit?: number
|
|
121
113
|
/** Track dependencies between tasks. If false, any change during build will error. */
|
|
122
|
-
dependencyTracking?: boolean
|
|
114
|
+
dependencyTracking?: boolean
|
|
123
115
|
}
|
|
124
|
-
export declare function projectNew(
|
|
125
|
-
|
|
126
|
-
turboEngineOptions: NapiTurboEngineOptions,
|
|
127
|
-
): Promise<{ __napiType: "Project" }>;
|
|
128
|
-
export declare function projectUpdate(
|
|
129
|
-
project: { __napiType: "Project" },
|
|
130
|
-
options: NapiPartialProjectOptions,
|
|
131
|
-
): Promise<void>;
|
|
116
|
+
export declare function projectNew(options: NapiProjectOptions, turboEngineOptions: NapiTurboEngineOptions): Promise<{ __napiType: "Project" }>
|
|
117
|
+
export declare function projectUpdate(project: { __napiType: "Project" }, options: NapiPartialProjectOptions): Promise<void>
|
|
132
118
|
/**
|
|
133
119
|
* Runs exit handlers for the project registered using the [`ExitHandler`] API.
|
|
134
120
|
*
|
|
135
121
|
* This is called by `project_shutdown`, so if you're calling that API, you shouldn't call this
|
|
136
122
|
* one.
|
|
137
123
|
*/
|
|
138
|
-
export declare function projectOnExit(project: {
|
|
139
|
-
__napiType: "Project";
|
|
140
|
-
}): Promise<void>;
|
|
124
|
+
export declare function projectOnExit(project: { __napiType: "Project" }): Promise<void>
|
|
141
125
|
/**
|
|
142
126
|
* Runs `project_on_exit`, and then waits for turbo_tasks to gracefully shut down.
|
|
143
127
|
*
|
|
@@ -145,39 +129,25 @@ export declare function projectOnExit(project: {
|
|
|
145
129
|
* it's skipped in the development server (`project_on_exit` is used instead with a short timeout),
|
|
146
130
|
* where we prioritize fast exit and user responsiveness over all else.
|
|
147
131
|
*/
|
|
148
|
-
export declare function projectShutdown(project: {
|
|
149
|
-
__napiType: "Project";
|
|
150
|
-
}): Promise<void>;
|
|
132
|
+
export declare function projectShutdown(project: { __napiType: "Project" }): Promise<void>
|
|
151
133
|
export interface NapiEntrypoints {
|
|
152
|
-
apps?: Array<ExternalObject<ExternalEndpoint
|
|
153
|
-
libraries?: Array<ExternalObject<ExternalEndpoint
|
|
134
|
+
apps?: Array<ExternalObject<ExternalEndpoint>>
|
|
135
|
+
libraries?: Array<ExternalObject<ExternalEndpoint>>
|
|
154
136
|
}
|
|
155
|
-
export declare function projectWriteAllEntrypointsToDisk(project: {
|
|
156
|
-
|
|
157
|
-
}):
|
|
158
|
-
export declare function projectEntrypointsSubscribe(
|
|
159
|
-
project: { __napiType: "Project" },
|
|
160
|
-
func: (...args: any[]) => any,
|
|
161
|
-
): { __napiType: "RootTask" };
|
|
162
|
-
export declare function projectHmrEvents(
|
|
163
|
-
project: { __napiType: "Project" },
|
|
164
|
-
identifier: string,
|
|
165
|
-
func: (...args: any[]) => any,
|
|
166
|
-
): { __napiType: "RootTask" };
|
|
137
|
+
export declare function projectWriteAllEntrypointsToDisk(project: { __napiType: "Project" }): Promise<TurbopackResult>
|
|
138
|
+
export declare function projectEntrypointsSubscribe(project: { __napiType: "Project" }, func: (...args: any[]) => any): { __napiType: "RootTask" }
|
|
139
|
+
export declare function projectHmrEvents(project: { __napiType: "Project" }, identifier: string, func: (...args: any[]) => any): { __napiType: "RootTask" }
|
|
167
140
|
export interface HmrIdentifiers {
|
|
168
|
-
identifiers: Array<string
|
|
141
|
+
identifiers: Array<string>
|
|
169
142
|
}
|
|
170
|
-
export declare function projectHmrIdentifiersSubscribe(
|
|
171
|
-
project: { __napiType: "Project" },
|
|
172
|
-
func: (...args: any[]) => any,
|
|
173
|
-
): { __napiType: "RootTask" };
|
|
143
|
+
export declare function projectHmrIdentifiersSubscribe(project: { __napiType: "Project" }, func: (...args: any[]) => any): { __napiType: "RootTask" }
|
|
174
144
|
export interface NapiUpdateMessage {
|
|
175
|
-
updateType: string
|
|
176
|
-
value?: NapiUpdateInfo
|
|
145
|
+
updateType: string
|
|
146
|
+
value?: NapiUpdateInfo
|
|
177
147
|
}
|
|
178
148
|
export interface NapiUpdateInfo {
|
|
179
|
-
duration: number
|
|
180
|
-
tasks: number
|
|
149
|
+
duration: number
|
|
150
|
+
tasks: number
|
|
181
151
|
}
|
|
182
152
|
/**
|
|
183
153
|
* Subscribes to lifecycle events of the compilation.
|
|
@@ -192,84 +162,61 @@ export interface NapiUpdateInfo {
|
|
|
192
162
|
*
|
|
193
163
|
* The signature of the `func` is `(update_message: UpdateMessage) => void`.
|
|
194
164
|
*/
|
|
195
|
-
export declare function projectUpdateInfoSubscribe(
|
|
196
|
-
project: { __napiType: "Project" },
|
|
197
|
-
aggregationMs: number,
|
|
198
|
-
func: (...args: any[]) => any,
|
|
199
|
-
): void;
|
|
165
|
+
export declare function projectUpdateInfoSubscribe(project: { __napiType: "Project" }, aggregationMs: number, func: (...args: any[]) => any): void
|
|
200
166
|
export interface StackFrame {
|
|
201
|
-
isServer: boolean
|
|
202
|
-
isInternal?: boolean
|
|
203
|
-
originalFile?: string
|
|
204
|
-
file: string
|
|
205
|
-
line?: number
|
|
206
|
-
column?: number
|
|
207
|
-
methodName?: string
|
|
208
|
-
}
|
|
209
|
-
export declare function projectTraceSource(
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
export declare function projectGetSourceForAsset(
|
|
215
|
-
project: { __napiType: "Project" },
|
|
216
|
-
filePath: string,
|
|
217
|
-
): Promise<string | null>;
|
|
218
|
-
export declare function projectGetSourceMap(
|
|
219
|
-
project: { __napiType: "Project" },
|
|
220
|
-
filePath: string,
|
|
221
|
-
): Promise<string | null>;
|
|
222
|
-
export declare function projectGetSourceMapSync(
|
|
223
|
-
project: { __napiType: "Project" },
|
|
224
|
-
filePath: string,
|
|
225
|
-
): string | null;
|
|
226
|
-
export declare function rootTaskDispose(rootTask: {
|
|
227
|
-
__napiType: "RootTask";
|
|
228
|
-
}): void;
|
|
167
|
+
isServer: boolean
|
|
168
|
+
isInternal?: boolean
|
|
169
|
+
originalFile?: string
|
|
170
|
+
file: string
|
|
171
|
+
line?: number
|
|
172
|
+
column?: number
|
|
173
|
+
methodName?: string
|
|
174
|
+
}
|
|
175
|
+
export declare function projectTraceSource(project: { __napiType: "Project" }, frame: StackFrame, currentDirectoryFileUrl: string): Promise<StackFrame | null>
|
|
176
|
+
export declare function projectGetSourceForAsset(project: { __napiType: "Project" }, filePath: string): Promise<string | null>
|
|
177
|
+
export declare function projectGetSourceMap(project: { __napiType: "Project" }, filePath: string): Promise<string | null>
|
|
178
|
+
export declare function projectGetSourceMapSync(project: { __napiType: "Project" }, filePath: string): string | null
|
|
179
|
+
export declare function rootTaskDispose(rootTask: { __napiType: "RootTask" }): void
|
|
229
180
|
export interface NapiIssue {
|
|
230
|
-
severity: string
|
|
231
|
-
stage: string
|
|
232
|
-
filePath: string
|
|
233
|
-
title: any
|
|
234
|
-
description?: any
|
|
235
|
-
detail?: any
|
|
236
|
-
source?: NapiIssueSource
|
|
237
|
-
documentationLink: string
|
|
238
|
-
subIssues: Array<NapiIssue
|
|
181
|
+
severity: string
|
|
182
|
+
stage: string
|
|
183
|
+
filePath: string
|
|
184
|
+
title: any
|
|
185
|
+
description?: any
|
|
186
|
+
detail?: any
|
|
187
|
+
source?: NapiIssueSource
|
|
188
|
+
documentationLink: string
|
|
189
|
+
subIssues: Array<NapiIssue>
|
|
239
190
|
}
|
|
240
191
|
export interface NapiIssueSource {
|
|
241
|
-
source: NapiSource
|
|
242
|
-
range?: NapiIssueSourceRange
|
|
192
|
+
source: NapiSource
|
|
193
|
+
range?: NapiIssueSourceRange
|
|
243
194
|
}
|
|
244
195
|
export interface NapiIssueSourceRange {
|
|
245
|
-
start: NapiSourcePos
|
|
246
|
-
end: NapiSourcePos
|
|
196
|
+
start: NapiSourcePos
|
|
197
|
+
end: NapiSourcePos
|
|
247
198
|
}
|
|
248
199
|
export interface NapiSource {
|
|
249
|
-
ident: string
|
|
250
|
-
content?: string
|
|
200
|
+
ident: string
|
|
201
|
+
content?: string
|
|
251
202
|
}
|
|
252
203
|
export interface NapiSourcePos {
|
|
253
|
-
line: number
|
|
254
|
-
column: number
|
|
204
|
+
line: number
|
|
205
|
+
column: number
|
|
255
206
|
}
|
|
256
207
|
export interface NapiDiagnostic {
|
|
257
|
-
category: string
|
|
258
|
-
name: string
|
|
259
|
-
payload: Record<string, string
|
|
208
|
+
category: string
|
|
209
|
+
name: string
|
|
210
|
+
payload: Record<string, string>
|
|
260
211
|
}
|
|
261
212
|
/**
|
|
262
213
|
* Initialize tracing subscriber to emit traces. This configures subscribers
|
|
263
214
|
* for Trace Event Format <https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview>.
|
|
264
215
|
*/
|
|
265
|
-
export declare function initCustomTraceSubscriber(
|
|
266
|
-
traceOutFilePath?: string | undefined | null,
|
|
267
|
-
): ExternalObject<RefCell>;
|
|
216
|
+
export declare function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): ExternalObject<RefCell>
|
|
268
217
|
/**
|
|
269
218
|
* Teardown currently running tracing subscriber to flush out remaining traces.
|
|
270
219
|
* This should be called when parent node.js process exits, otherwise generated
|
|
271
220
|
* trace may drop traces in the buffer.
|
|
272
221
|
*/
|
|
273
|
-
export declare function teardownTraceSubscriber(
|
|
274
|
-
guardExternal: ExternalObject<RefCell>,
|
|
275
|
-
): void;
|
|
222
|
+
export declare function teardownTraceSubscriber(guardExternal: ExternalObject<RefCell>): void
|
package/cjs/build.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { BundleOptions } from "./types";
|
|
2
|
-
|
|
2
|
+
import { WebpackConfig } from "./webpackCompat";
|
|
3
|
+
export declare function build(bundleOptions: BundleOptions, projectPath?: string, rootPath?: string): Promise<void>;
|
|
4
|
+
export declare function build(webpackConfig: WebpackConfig, projectPath?: string, rootPath?: string): Promise<void>;
|
package/cjs/build.js
CHANGED
|
@@ -4,27 +4,34 @@ exports.build = build;
|
|
|
4
4
|
const nanoid_1 = require("nanoid");
|
|
5
5
|
const project_1 = require("./project");
|
|
6
6
|
const util_1 = require("./util");
|
|
7
|
+
const webpackCompat_1 = require("./webpackCompat");
|
|
7
8
|
const xcodeProfile_1 = require("./xcodeProfile");
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
function build(options, projectPath, rootPath) {
|
|
10
|
+
const bundleOptions = options.compatMode
|
|
11
|
+
? (0, webpackCompat_1.compatOptionsFromWebpack)(options)
|
|
12
|
+
: options;
|
|
13
|
+
return buildInternal(bundleOptions, projectPath, rootPath);
|
|
14
|
+
}
|
|
15
|
+
async function buildInternal(bundleOptions, projectPath, rootPath) {
|
|
16
|
+
var _a, _b, _c;
|
|
10
17
|
(0, util_1.blockStdout)();
|
|
11
18
|
if (process.env.XCODE_PROFILE) {
|
|
12
19
|
await (0, xcodeProfile_1.xcodeProfilingReady)();
|
|
13
20
|
}
|
|
14
21
|
const createProject = (0, project_1.projectFactory)();
|
|
15
22
|
const project = await createProject({
|
|
16
|
-
processEnv: (_a =
|
|
17
|
-
|
|
18
|
-
config:
|
|
19
|
-
dev: (_b =
|
|
20
|
-
optionDefineEnv:
|
|
23
|
+
processEnv: (_a = bundleOptions.processEnv) !== null && _a !== void 0 ? _a : {},
|
|
24
|
+
defineEnv: (0, util_1.createDefineEnv)({
|
|
25
|
+
config: bundleOptions.config,
|
|
26
|
+
dev: (_b = bundleOptions.dev) !== null && _b !== void 0 ? _b : false,
|
|
27
|
+
optionDefineEnv: bundleOptions.defineEnv,
|
|
21
28
|
}),
|
|
22
|
-
watch:
|
|
29
|
+
watch: {
|
|
23
30
|
enable: false,
|
|
24
31
|
},
|
|
25
|
-
dev: (
|
|
26
|
-
buildId: (0, nanoid_1.nanoid)(),
|
|
27
|
-
config:
|
|
32
|
+
dev: (_c = bundleOptions.dev) !== null && _c !== void 0 ? _c : false,
|
|
33
|
+
buildId: bundleOptions.buildId || (0, nanoid_1.nanoid)(),
|
|
34
|
+
config: bundleOptions.config,
|
|
28
35
|
projectPath: projectPath || process.cwd(),
|
|
29
36
|
rootPath: rootPath || projectPath || process.cwd(),
|
|
30
37
|
}, {
|
package/cjs/dev.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import { IncomingMessage, ServerResponse } from "http";
|
|
|
2
2
|
import send from "send";
|
|
3
3
|
import { Duplex, Writable } from "stream";
|
|
4
4
|
import { BundleOptions } from "./types";
|
|
5
|
-
|
|
5
|
+
import { WebpackConfig } from "./webpackCompat";
|
|
6
|
+
export declare function serve(bundleOptions: BundleOptions, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
|
|
7
|
+
export declare function serve(webpackConfig: WebpackConfig, projectPath?: string, rootPath?: string, serverOptions?: StartServerOptions): Promise<void>;
|
|
6
8
|
export interface SelfSignedCertificate {
|
|
7
9
|
key: string;
|
|
8
10
|
cert: string;
|
package/cjs/dev.js
CHANGED
|
@@ -22,8 +22,15 @@ const url_1 = __importDefault(require("url"));
|
|
|
22
22
|
const hmr_1 = require("./hmr");
|
|
23
23
|
const mkcert_1 = require("./mkcert");
|
|
24
24
|
const util_1 = require("./util");
|
|
25
|
+
const webpackCompat_1 = require("./webpackCompat");
|
|
25
26
|
const xcodeProfile_1 = require("./xcodeProfile");
|
|
26
|
-
|
|
27
|
+
function serve(options, projectPath, rootPath, serverOptions) {
|
|
28
|
+
const bundleOptions = options.compatMode
|
|
29
|
+
? (0, webpackCompat_1.compatOptionsFromWebpack)(options)
|
|
30
|
+
: options;
|
|
31
|
+
return serveInternal(bundleOptions, projectPath, rootPath, serverOptions);
|
|
32
|
+
}
|
|
33
|
+
async function serveInternal(options, projectPath, rootPath, serverOptions) {
|
|
27
34
|
(0, util_1.blockStdout)();
|
|
28
35
|
if (process.env.XCODE_PROFILE) {
|
|
29
36
|
await (0, xcodeProfile_1.xcodeProfilingReady)();
|
|
@@ -35,7 +42,7 @@ async function serve(options, projectPath, rootPath, serverOptions) {
|
|
|
35
42
|
selfSignedCertificate: (serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.https)
|
|
36
43
|
? await (0, mkcert_1.createSelfSignedCertificate)((serverOptions === null || serverOptions === void 0 ? void 0 : serverOptions.hostname) || "localhost")
|
|
37
44
|
: undefined,
|
|
38
|
-
}, options, projectPath, rootPath);
|
|
45
|
+
}, options, projectPath || process.cwd(), rootPath);
|
|
39
46
|
}
|
|
40
47
|
async function startServer(serverOptions, bundleOptions, projectPath, rootPath) {
|
|
41
48
|
let { port, hostname, selfSignedCertificate } = serverOptions;
|
package/cjs/hmr.js
CHANGED
|
@@ -17,16 +17,16 @@ async function createHotReloader(bundleOptions, projectPath, rootPath) {
|
|
|
17
17
|
const createProject = (0, project_1.projectFactory)();
|
|
18
18
|
const project = await createProject({
|
|
19
19
|
processEnv: (_a = bundleOptions.processEnv) !== null && _a !== void 0 ? _a : {},
|
|
20
|
-
|
|
20
|
+
defineEnv: (0, util_1.createDefineEnv)({
|
|
21
21
|
config: bundleOptions.config,
|
|
22
22
|
dev: true,
|
|
23
|
-
optionDefineEnv: bundleOptions.
|
|
23
|
+
optionDefineEnv: bundleOptions.defineEnv,
|
|
24
24
|
}),
|
|
25
25
|
watch: {
|
|
26
26
|
enable: true,
|
|
27
27
|
},
|
|
28
28
|
dev: true,
|
|
29
|
-
buildId: (0, nanoid_1.nanoid)(),
|
|
29
|
+
buildId: bundleOptions.buildId || (0, nanoid_1.nanoid)(),
|
|
30
30
|
config: {
|
|
31
31
|
...bundleOptions.config,
|
|
32
32
|
mode: "development",
|
package/cjs/index.d.ts
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { build } from "./build";
|
|
2
|
+
import { serve } from "./dev";
|
|
3
|
+
import * as webpackCompat from "./webpackCompat";
|
|
4
|
+
export { build };
|
|
5
|
+
export { serve };
|
|
6
|
+
declare const utoopack: {
|
|
7
|
+
build: typeof build;
|
|
8
|
+
serve: typeof serve;
|
|
9
|
+
};
|
|
10
|
+
export default utoopack;
|
|
11
|
+
export type WebpackConfig = webpackCompat.WebpackConfig;
|
|
12
|
+
declare namespace utoopack {
|
|
13
|
+
type WebpackConfig = webpackCompat.WebpackConfig;
|
|
14
|
+
}
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serve = exports.build = void 0;
|
|
4
|
-
|
|
4
|
+
const build_1 = require("./build");
|
|
5
5
|
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return build_1.build; } });
|
|
6
|
-
|
|
6
|
+
const dev_1 = require("./dev");
|
|
7
7
|
Object.defineProperty(exports, "serve", { enumerable: true, get: function () { return dev_1.serve; } });
|
|
8
|
+
const utoopack = { build: build_1.build, serve: dev_1.serve };
|
|
9
|
+
exports.default = utoopack;
|
package/cjs/project.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare class TurbopackInternalError extends Error {
|
|
|
5
5
|
name: string;
|
|
6
6
|
constructor(cause: Error);
|
|
7
7
|
}
|
|
8
|
-
export declare function projectFactory(): (options: ProjectOptions
|
|
8
|
+
export declare function projectFactory(): (options: Required<ProjectOptions>, turboEngineOptions: binding.NapiTurboEngineOptions) => Promise<{
|
|
9
9
|
readonly _nativeProject: {
|
|
10
10
|
__napiType: "Project";
|
|
11
11
|
};
|
package/cjs/project.js
CHANGED
|
@@ -35,7 +35,6 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.TurbopackInternalError = void 0;
|
|
37
37
|
exports.projectFactory = projectFactory;
|
|
38
|
-
const nanoid_1 = require("nanoid");
|
|
39
38
|
const util_1 = require("util");
|
|
40
39
|
const binding = __importStar(require("./binding"));
|
|
41
40
|
const util_2 = require("./util");
|
|
@@ -91,7 +90,6 @@ function ensureLoadersHaveSerializableOptions(turbopackRules) {
|
|
|
91
90
|
async function serializeConfig(config) {
|
|
92
91
|
var _a, _b;
|
|
93
92
|
let configSerializable = { ...config };
|
|
94
|
-
configSerializable.generateBuildId = () => (0, nanoid_1.nanoid)();
|
|
95
93
|
if ((_a = configSerializable.module) === null || _a === void 0 ? void 0 : _a.rules) {
|
|
96
94
|
ensureLoadersHaveSerializableOptions(configSerializable.module.rules);
|
|
97
95
|
}
|
package/cjs/types.d.ts
CHANGED
|
@@ -65,7 +65,6 @@ export interface DefineEnv {
|
|
|
65
65
|
}
|
|
66
66
|
export interface ExperimentalConfig {
|
|
67
67
|
}
|
|
68
|
-
export type TurbopackRuleConfigItemOrShortcut = TurbopackRuleConfigItem;
|
|
69
68
|
export type TurbopackRuleConfigItem = TurbopackRuleConfigItemOptions | {
|
|
70
69
|
[condition: string]: TurbopackRuleConfigItem;
|
|
71
70
|
} | false;
|
|
@@ -81,7 +80,7 @@ export type TurbopackRuleConfigItemOptions = {
|
|
|
81
80
|
as?: string;
|
|
82
81
|
};
|
|
83
82
|
export interface ModuleOptions {
|
|
84
|
-
rules?: Record<string,
|
|
83
|
+
rules?: Record<string, TurbopackRuleConfigItem>;
|
|
85
84
|
}
|
|
86
85
|
export interface ResolveOptions {
|
|
87
86
|
alias?: Record<string, string | string[] | Record<string, string | string[]>>;
|
|
@@ -152,6 +151,7 @@ export interface ConfigComplete {
|
|
|
152
151
|
images?: {
|
|
153
152
|
inlineLimit?: number;
|
|
154
153
|
};
|
|
154
|
+
stats?: boolean;
|
|
155
155
|
experimental?: ExperimentalConfig;
|
|
156
156
|
persistentCaching?: boolean;
|
|
157
157
|
cacheHandler?: string;
|
|
@@ -205,23 +205,23 @@ export interface ProjectOptions {
|
|
|
205
205
|
/**
|
|
206
206
|
* A map of environment variables to use when compiling code.
|
|
207
207
|
*/
|
|
208
|
-
processEnv
|
|
209
|
-
|
|
208
|
+
processEnv?: Record<string, string>;
|
|
209
|
+
defineEnv?: DefineEnv;
|
|
210
210
|
/**
|
|
211
211
|
* Whether to watch the filesystem for file changes.
|
|
212
212
|
*/
|
|
213
|
-
watch
|
|
213
|
+
watch?: {
|
|
214
214
|
enable: boolean;
|
|
215
215
|
pollIntervalMs?: number;
|
|
216
216
|
};
|
|
217
217
|
/**
|
|
218
218
|
* The mode of utoo-pack.
|
|
219
219
|
*/
|
|
220
|
-
dev
|
|
220
|
+
dev?: boolean;
|
|
221
221
|
/**
|
|
222
222
|
* The build id.
|
|
223
223
|
*/
|
|
224
|
-
buildId
|
|
224
|
+
buildId?: string;
|
|
225
225
|
}
|
|
226
226
|
export type BundleOptions = Omit<ProjectOptions, "rootPath" | "projectPath">;
|
|
227
227
|
export interface Project {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type webpack from "webpack";
|
|
2
|
+
import { BundleOptions } from "./types";
|
|
3
|
+
export type WebpackConfig = Pick<webpack.Configuration, "name" | "entry" | "mode" | "module" | "resolve" | "externals" | "output" | "target" | "devtool" | "optimization" | "plugins" | "stats"> & {
|
|
4
|
+
compatMode: true;
|
|
5
|
+
};
|
|
6
|
+
export declare function compatOptionsFromWebpack(webpackConfig: WebpackConfig): BundleOptions;
|