@utoo/pack 0.0.1-alpha.1

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/bin/cli.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ const { build } = require("../cjs/index.js");
3
+
4
+ console.log(process.argv);
5
+
6
+ // Get the directory argument, default to current directory
7
+ const dir = process.argv[2] || process.cwd();
8
+
9
+ build(dir);
@@ -0,0 +1,222 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+
4
+ /* auto-generated by NAPI-RS */
5
+
6
+ export declare class ExternalObject<T> {
7
+ readonly '': {
8
+ readonly '': unique symbol
9
+ [K: symbol]: T
10
+ }
11
+ }
12
+ export interface TransformOutput {
13
+ code: string
14
+ map?: string
15
+ output?: string
16
+ diagnostics: Array<string>
17
+ }
18
+ export interface NapiEndpointConfig {
19
+
20
+ }
21
+ export interface NapiServerPath {
22
+ path: string
23
+ contentHash: string
24
+ }
25
+ export interface NapiWrittenEndpoint {
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" }
35
+ export interface NapiEnvVar {
36
+ name: string
37
+ value: string
38
+ }
39
+ export interface NapiWatchOptions {
40
+ /** Whether to watch the filesystem for file changes. */
41
+ enable: boolean
42
+ /**
43
+ * Enable polling at a certain interval if the native file watching doesn't work (e.g.
44
+ * docker).
45
+ */
46
+ pollIntervalMs?: number
47
+ }
48
+ export interface NapiProjectOptions {
49
+ /**
50
+ * A root path from which all files must be nested under. Trying to access
51
+ * a file outside this root will fail. Think of this as a chroot.
52
+ */
53
+ rootPath: string
54
+ /** A path inside the root_path which contains the app/pages directories. */
55
+ projectPath: string
56
+ /** Filesystem watcher options. */
57
+ watch: NapiWatchOptions
58
+ /** The contents of config.js, serialized to JSON. */
59
+ config: string
60
+ /** A map of environment variables to use when compiling code. */
61
+ processEnv: Array<NapiEnvVar>
62
+ /**
63
+ * A map of environment variables which should get injected at compile
64
+ * time.
65
+ */
66
+ processDefineEnv: NapiDefineEnv
67
+ /** The mode in which Next.js is running. */
68
+ dev: boolean
69
+ /** The build id. */
70
+ buildId: string
71
+ }
72
+ /** [NapiProjectOptions] with all fields optional. */
73
+ export interface NapiPartialProjectOptions {
74
+ /**
75
+ * A root path from which all files must be nested under. Trying to access
76
+ * a file outside this root will fail. Think of this as a chroot.
77
+ */
78
+ rootPath?: string
79
+ /** A path inside the root_path which contains the app/pages directories. */
80
+ projectPath?: string
81
+ /** Filesystem watcher options. */
82
+ watch?: NapiWatchOptions
83
+ /** The contents of config.js, serialized to JSON. */
84
+ config?: string
85
+ /** A map of environment variables to use when compiling code. */
86
+ processEnv?: Array<NapiEnvVar>
87
+ /**
88
+ * A map of environment variables which should get injected at compile
89
+ * time.
90
+ */
91
+ processDefineEnv?: NapiDefineEnv
92
+ /** The mode in which Next.js is running. */
93
+ dev?: boolean
94
+ /** The build id. */
95
+ buildId?: string
96
+ /**
97
+ * When the code is minified, this opts out of the default mangling of
98
+ * local names for variables, functions etc., which can be useful for
99
+ * debugging/profiling purposes.
100
+ */
101
+ noMangling?: boolean
102
+ }
103
+ export interface NapiDefineEnv {
104
+ client: Array<NapiEnvVar>
105
+ edge: Array<NapiEnvVar>
106
+ nodejs: Array<NapiEnvVar>
107
+ }
108
+ export interface NapiTurboEngineOptions {
109
+ /** Use the new backend with persistent caching enabled. */
110
+ persistentCaching?: boolean
111
+ /** An upper bound of memory that turbopack will attempt to stay under. */
112
+ memoryLimit?: number
113
+ /** Track dependencies between tasks. If false, any change during build will error. */
114
+ dependencyTracking?: boolean
115
+ }
116
+ export declare function projectNew(options: NapiProjectOptions, turboEngineOptions: NapiTurboEngineOptions): Promise<{ __napiType: "Project" }>
117
+ export declare function projectUpdate(project: { __napiType: "Project" }, options: NapiPartialProjectOptions): Promise<void>
118
+ /**
119
+ * Runs exit handlers for the project registered using the [`ExitHandler`] API.
120
+ *
121
+ * This is called by `project_shutdown`, so if you're calling that API, you shouldn't call this
122
+ * one.
123
+ */
124
+ export declare function projectOnExit(project: { __napiType: "Project" }): Promise<void>
125
+ /**
126
+ * Runs `project_on_exit`, and then waits for turbo_tasks to gracefully shut down.
127
+ *
128
+ * This is used in builds where it's important that we completely persist turbo-tasks to disk, but
129
+ * it's skipped in the development server (`project_on_exit` is used instead with a short timeout),
130
+ * where we prioritize fast exit and user responsiveness over all else.
131
+ */
132
+ export declare function projectShutdown(project: { __napiType: "Project" }): Promise<void>
133
+ export interface NapiEntrypoints {
134
+ apps?: Array<ExternalObject<ExternalEndpoint>>
135
+ libraries?: Array<ExternalObject<ExternalEndpoint>>
136
+ }
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" }
140
+ export interface HmrIdentifiers {
141
+ identifiers: Array<string>
142
+ }
143
+ export declare function projectHmrIdentifiersSubscribe(project: { __napiType: "Project" }, func: (...args: any[]) => any): { __napiType: "RootTask" }
144
+ export interface NapiUpdateMessage {
145
+ updateType: string
146
+ value?: NapiUpdateInfo
147
+ }
148
+ export interface NapiUpdateInfo {
149
+ duration: number
150
+ tasks: number
151
+ }
152
+ /**
153
+ * Subscribes to lifecycle events of the compilation.
154
+ *
155
+ * Emits an [UpdateMessage::Start] event when any computation starts.
156
+ * Emits an [UpdateMessage::End] event when there was no computation for the
157
+ * specified time (`aggregation_ms`). The [UpdateMessage::End] event contains
158
+ * information about the computations that happened since the
159
+ * [UpdateMessage::Start] event. It contains the duration of the computation
160
+ * (excluding the idle time that was spend waiting for `aggregation_ms`), and
161
+ * the number of tasks that were executed.
162
+ *
163
+ * The signature of the `func` is `(update_message: UpdateMessage) => void`.
164
+ */
165
+ export declare function projectUpdateInfoSubscribe(project: { __napiType: "Project" }, aggregationMs: number, func: (...args: any[]) => any): void
166
+ export interface StackFrame {
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
180
+ export interface 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>
190
+ }
191
+ export interface NapiIssueSource {
192
+ source: NapiSource
193
+ range?: NapiIssueSourceRange
194
+ }
195
+ export interface NapiIssueSourceRange {
196
+ start: NapiSourcePos
197
+ end: NapiSourcePos
198
+ }
199
+ export interface NapiSource {
200
+ ident: string
201
+ content?: string
202
+ }
203
+ export interface NapiSourcePos {
204
+ line: number
205
+ column: number
206
+ }
207
+ export interface NapiDiagnostic {
208
+ category: string
209
+ name: string
210
+ payload: Record<string, string>
211
+ }
212
+ /**
213
+ * Initialize tracing subscriber to emit traces. This configures subscribers
214
+ * for Trace Event Format <https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview>.
215
+ */
216
+ export declare function initCustomTraceSubscriber(traceOutFilePath?: string | undefined | null): ExternalObject<RefCell>
217
+ /**
218
+ * Teardown currently running tracing subscriber to flush out remaining traces.
219
+ * This should be called when parent node.js process exits, otherwise generated
220
+ * trace may drop traces in the buffer.
221
+ */
222
+ export declare function teardownTraceSubscriber(guardExternal: ExternalObject<RefCell>): void
package/cjs/binding.js ADDED
@@ -0,0 +1,341 @@
1
+ "use strict";
2
+ /* tslint:disable */
3
+ /* eslint-disable */
4
+ /* prettier-ignore */
5
+ /* auto-generated by NAPI-RS */
6
+ const { existsSync, readFileSync } = require('fs');
7
+ const { join } = require('path');
8
+ const { platform, arch } = process;
9
+ let nativeBinding = null;
10
+ let localFileExisted = false;
11
+ let loadError = null;
12
+ function isMusl() {
13
+ // For Node 10
14
+ if (!process.report || typeof process.report.getReport !== 'function') {
15
+ try {
16
+ const lddPath = require('child_process').execSync('which ldd').toString().trim();
17
+ return readFileSync(lddPath, 'utf8').includes('musl');
18
+ }
19
+ catch (e) {
20
+ return true;
21
+ }
22
+ }
23
+ else {
24
+ const { glibcVersionRuntime } = process.report.getReport().header;
25
+ return !glibcVersionRuntime;
26
+ }
27
+ }
28
+ switch (platform) {
29
+ case 'android':
30
+ switch (arch) {
31
+ case 'arm64':
32
+ localFileExisted = existsSync(join(__dirname, 'pack.android-arm64.node'));
33
+ try {
34
+ if (localFileExisted) {
35
+ nativeBinding = require('./pack.android-arm64.node');
36
+ }
37
+ else {
38
+ nativeBinding = require('@utoo/pack-android-arm64');
39
+ }
40
+ }
41
+ catch (e) {
42
+ loadError = e;
43
+ }
44
+ break;
45
+ case 'arm':
46
+ localFileExisted = existsSync(join(__dirname, 'pack.android-arm-eabi.node'));
47
+ try {
48
+ if (localFileExisted) {
49
+ nativeBinding = require('./pack.android-arm-eabi.node');
50
+ }
51
+ else {
52
+ nativeBinding = require('@utoo/pack-android-arm-eabi');
53
+ }
54
+ }
55
+ catch (e) {
56
+ loadError = e;
57
+ }
58
+ break;
59
+ default:
60
+ throw new Error(`Unsupported architecture on Android ${arch}`);
61
+ }
62
+ break;
63
+ case 'win32':
64
+ switch (arch) {
65
+ case 'x64':
66
+ localFileExisted = existsSync(join(__dirname, 'pack.win32-x64-msvc.node'));
67
+ try {
68
+ if (localFileExisted) {
69
+ nativeBinding = require('./pack.win32-x64-msvc.node');
70
+ }
71
+ else {
72
+ nativeBinding = require('@utoo/pack-win32-x64-msvc');
73
+ }
74
+ }
75
+ catch (e) {
76
+ loadError = e;
77
+ }
78
+ break;
79
+ case 'ia32':
80
+ localFileExisted = existsSync(join(__dirname, 'pack.win32-ia32-msvc.node'));
81
+ try {
82
+ if (localFileExisted) {
83
+ nativeBinding = require('./pack.win32-ia32-msvc.node');
84
+ }
85
+ else {
86
+ nativeBinding = require('@utoo/pack-win32-ia32-msvc');
87
+ }
88
+ }
89
+ catch (e) {
90
+ loadError = e;
91
+ }
92
+ break;
93
+ case 'arm64':
94
+ localFileExisted = existsSync(join(__dirname, 'pack.win32-arm64-msvc.node'));
95
+ try {
96
+ if (localFileExisted) {
97
+ nativeBinding = require('./pack.win32-arm64-msvc.node');
98
+ }
99
+ else {
100
+ nativeBinding = require('@utoo/pack-win32-arm64-msvc');
101
+ }
102
+ }
103
+ catch (e) {
104
+ loadError = e;
105
+ }
106
+ break;
107
+ default:
108
+ throw new Error(`Unsupported architecture on Windows: ${arch}`);
109
+ }
110
+ break;
111
+ case 'darwin':
112
+ localFileExisted = existsSync(join(__dirname, 'pack.darwin-universal.node'));
113
+ try {
114
+ if (localFileExisted) {
115
+ nativeBinding = require('./pack.darwin-universal.node');
116
+ }
117
+ else {
118
+ nativeBinding = require('@utoo/pack-darwin-universal');
119
+ }
120
+ break;
121
+ }
122
+ catch (_a) { }
123
+ switch (arch) {
124
+ case 'x64':
125
+ localFileExisted = existsSync(join(__dirname, 'pack.darwin-x64.node'));
126
+ try {
127
+ if (localFileExisted) {
128
+ nativeBinding = require('./pack.darwin-x64.node');
129
+ }
130
+ else {
131
+ nativeBinding = require('@utoo/pack-darwin-x64');
132
+ }
133
+ }
134
+ catch (e) {
135
+ loadError = e;
136
+ }
137
+ break;
138
+ case 'arm64':
139
+ localFileExisted = existsSync(join(__dirname, 'pack.darwin-arm64.node'));
140
+ try {
141
+ if (localFileExisted) {
142
+ nativeBinding = require('./pack.darwin-arm64.node');
143
+ }
144
+ else {
145
+ nativeBinding = require('@utoo/pack-darwin-arm64');
146
+ }
147
+ }
148
+ catch (e) {
149
+ loadError = e;
150
+ }
151
+ break;
152
+ default:
153
+ throw new Error(`Unsupported architecture on macOS: ${arch}`);
154
+ }
155
+ break;
156
+ case 'freebsd':
157
+ if (arch !== 'x64') {
158
+ throw new Error(`Unsupported architecture on FreeBSD: ${arch}`);
159
+ }
160
+ localFileExisted = existsSync(join(__dirname, 'pack.freebsd-x64.node'));
161
+ try {
162
+ if (localFileExisted) {
163
+ nativeBinding = require('./pack.freebsd-x64.node');
164
+ }
165
+ else {
166
+ nativeBinding = require('@utoo/pack-freebsd-x64');
167
+ }
168
+ }
169
+ catch (e) {
170
+ loadError = e;
171
+ }
172
+ break;
173
+ case 'linux':
174
+ switch (arch) {
175
+ case 'x64':
176
+ if (isMusl()) {
177
+ localFileExisted = existsSync(join(__dirname, 'pack.linux-x64-musl.node'));
178
+ try {
179
+ if (localFileExisted) {
180
+ nativeBinding = require('./pack.linux-x64-musl.node');
181
+ }
182
+ else {
183
+ nativeBinding = require('@utoo/pack-linux-x64-musl');
184
+ }
185
+ }
186
+ catch (e) {
187
+ loadError = e;
188
+ }
189
+ }
190
+ else {
191
+ localFileExisted = existsSync(join(__dirname, 'pack.linux-x64-gnu.node'));
192
+ try {
193
+ if (localFileExisted) {
194
+ nativeBinding = require('./pack.linux-x64-gnu.node');
195
+ }
196
+ else {
197
+ nativeBinding = require('@utoo/pack-linux-x64-gnu');
198
+ }
199
+ }
200
+ catch (e) {
201
+ loadError = e;
202
+ }
203
+ }
204
+ break;
205
+ case 'arm64':
206
+ if (isMusl()) {
207
+ localFileExisted = existsSync(join(__dirname, 'pack.linux-arm64-musl.node'));
208
+ try {
209
+ if (localFileExisted) {
210
+ nativeBinding = require('./pack.linux-arm64-musl.node');
211
+ }
212
+ else {
213
+ nativeBinding = require('@utoo/pack-linux-arm64-musl');
214
+ }
215
+ }
216
+ catch (e) {
217
+ loadError = e;
218
+ }
219
+ }
220
+ else {
221
+ localFileExisted = existsSync(join(__dirname, 'pack.linux-arm64-gnu.node'));
222
+ try {
223
+ if (localFileExisted) {
224
+ nativeBinding = require('./pack.linux-arm64-gnu.node');
225
+ }
226
+ else {
227
+ nativeBinding = require('@utoo/pack-linux-arm64-gnu');
228
+ }
229
+ }
230
+ catch (e) {
231
+ loadError = e;
232
+ }
233
+ }
234
+ break;
235
+ case 'arm':
236
+ if (isMusl()) {
237
+ localFileExisted = existsSync(join(__dirname, 'pack.linux-arm-musleabihf.node'));
238
+ try {
239
+ if (localFileExisted) {
240
+ nativeBinding = require('./pack.linux-arm-musleabihf.node');
241
+ }
242
+ else {
243
+ nativeBinding = require('@utoo/pack-linux-arm-musleabihf');
244
+ }
245
+ }
246
+ catch (e) {
247
+ loadError = e;
248
+ }
249
+ }
250
+ else {
251
+ localFileExisted = existsSync(join(__dirname, 'pack.linux-arm-gnueabihf.node'));
252
+ try {
253
+ if (localFileExisted) {
254
+ nativeBinding = require('./pack.linux-arm-gnueabihf.node');
255
+ }
256
+ else {
257
+ nativeBinding = require('@utoo/pack-linux-arm-gnueabihf');
258
+ }
259
+ }
260
+ catch (e) {
261
+ loadError = e;
262
+ }
263
+ }
264
+ break;
265
+ case 'riscv64':
266
+ if (isMusl()) {
267
+ localFileExisted = existsSync(join(__dirname, 'pack.linux-riscv64-musl.node'));
268
+ try {
269
+ if (localFileExisted) {
270
+ nativeBinding = require('./pack.linux-riscv64-musl.node');
271
+ }
272
+ else {
273
+ nativeBinding = require('@utoo/pack-linux-riscv64-musl');
274
+ }
275
+ }
276
+ catch (e) {
277
+ loadError = e;
278
+ }
279
+ }
280
+ else {
281
+ localFileExisted = existsSync(join(__dirname, 'pack.linux-riscv64-gnu.node'));
282
+ try {
283
+ if (localFileExisted) {
284
+ nativeBinding = require('./pack.linux-riscv64-gnu.node');
285
+ }
286
+ else {
287
+ nativeBinding = require('@utoo/pack-linux-riscv64-gnu');
288
+ }
289
+ }
290
+ catch (e) {
291
+ loadError = e;
292
+ }
293
+ }
294
+ break;
295
+ case 's390x':
296
+ localFileExisted = existsSync(join(__dirname, 'pack.linux-s390x-gnu.node'));
297
+ try {
298
+ if (localFileExisted) {
299
+ nativeBinding = require('./pack.linux-s390x-gnu.node');
300
+ }
301
+ else {
302
+ nativeBinding = require('@utoo/pack-linux-s390x-gnu');
303
+ }
304
+ }
305
+ catch (e) {
306
+ loadError = e;
307
+ }
308
+ break;
309
+ default:
310
+ throw new Error(`Unsupported architecture on Linux: ${arch}`);
311
+ }
312
+ break;
313
+ default:
314
+ throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`);
315
+ }
316
+ if (!nativeBinding) {
317
+ if (loadError) {
318
+ throw loadError;
319
+ }
320
+ throw new Error(`Failed to load native binding`);
321
+ }
322
+ const { endpointWriteToDisk, endpointServerChangedSubscribe, endpointClientChangedSubscribe, projectNew, projectUpdate, projectOnExit, projectShutdown, projectWriteAllEntrypointsToDisk, projectEntrypointsSubscribe, projectHmrEvents, projectHmrIdentifiersSubscribe, projectUpdateInfoSubscribe, projectTraceSource, projectGetSourceForAsset, projectGetSourceMap, projectGetSourceMapSync, rootTaskDispose, initCustomTraceSubscriber, teardownTraceSubscriber } = nativeBinding;
323
+ module.exports.endpointWriteToDisk = endpointWriteToDisk;
324
+ module.exports.endpointServerChangedSubscribe = endpointServerChangedSubscribe;
325
+ module.exports.endpointClientChangedSubscribe = endpointClientChangedSubscribe;
326
+ module.exports.projectNew = projectNew;
327
+ module.exports.projectUpdate = projectUpdate;
328
+ module.exports.projectOnExit = projectOnExit;
329
+ module.exports.projectShutdown = projectShutdown;
330
+ module.exports.projectWriteAllEntrypointsToDisk = projectWriteAllEntrypointsToDisk;
331
+ module.exports.projectEntrypointsSubscribe = projectEntrypointsSubscribe;
332
+ module.exports.projectHmrEvents = projectHmrEvents;
333
+ module.exports.projectHmrIdentifiersSubscribe = projectHmrIdentifiersSubscribe;
334
+ module.exports.projectUpdateInfoSubscribe = projectUpdateInfoSubscribe;
335
+ module.exports.projectTraceSource = projectTraceSource;
336
+ module.exports.projectGetSourceForAsset = projectGetSourceForAsset;
337
+ module.exports.projectGetSourceMap = projectGetSourceMap;
338
+ module.exports.projectGetSourceMapSync = projectGetSourceMapSync;
339
+ module.exports.rootTaskDispose = rootTaskDispose;
340
+ module.exports.initCustomTraceSubscriber = initCustomTraceSubscriber;
341
+ module.exports.teardownTraceSubscriber = teardownTraceSubscriber;
package/cjs/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function build(dir?: string): Promise<void>;
package/cjs/index.js ADDED
@@ -0,0 +1,75 @@
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.build = build;
7
+ const nanoid_1 = require("nanoid");
8
+ const project_1 = require("./project");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const util_1 = require("./util");
12
+ const xcodeProfile_1 = require("./xcodeProfile");
13
+ // ref:
14
+ // https://github.com/vercel/next.js/pull/51883
15
+ function blockStdout() {
16
+ // rust needs stdout to be blocking, otherwise it will throw an error (on macOS at least) when writing a lot of data (logs) to it
17
+ // see https://github.com/napi-rs/napi-rs/issues/1630
18
+ // and https://github.com/nodejs/node/blob/main/doc/api/process.md#a-note-on-process-io
19
+ if (process.stdout._handle != null) {
20
+ process.stdout._handle.setBlocking(true);
21
+ }
22
+ if (process.stderr._handle != null) {
23
+ process.stderr._handle.setBlocking(true);
24
+ }
25
+ }
26
+ async function build(dir) {
27
+ var _a, _b, _c, _d;
28
+ blockStdout();
29
+ if (process.env.XCODE_PROFILE) {
30
+ await (0, xcodeProfile_1.xcodeProfilingReady)();
31
+ }
32
+ const cwd = dir || process.cwd();
33
+ const projectOptions = JSON.parse(fs_1.default.readFileSync(path_1.default.join(cwd, "project_options.json"), {
34
+ encoding: "utf-8",
35
+ }));
36
+ const createProject = (0, project_1.projectFactory)();
37
+ const project = await createProject({
38
+ processEnv: (_a = projectOptions.processEnv) !== null && _a !== void 0 ? _a : {},
39
+ processDefineEnv: (_b = projectOptions.processDefineEnv) !== null && _b !== void 0 ? _b : {
40
+ client: [],
41
+ nodejs: [],
42
+ edge: [],
43
+ },
44
+ watch: (_c = projectOptions.watch) !== null && _c !== void 0 ? _c : {
45
+ enable: false,
46
+ },
47
+ dev: (_d = projectOptions.dev) !== null && _d !== void 0 ? _d : false,
48
+ buildId: (0, nanoid_1.nanoid)(),
49
+ config: projectOptions.config,
50
+ rootPath: path_1.default.resolve(cwd, projectOptions.rootPath),
51
+ projectPath: path_1.default.resolve(cwd, projectOptions.projectPath),
52
+ }, {
53
+ persistentCaching: false,
54
+ });
55
+ const entrypoints = await project.writeAllEntrypointsToDisk();
56
+ const topLevelErrors = [];
57
+ const topLevelWarnings = [];
58
+ for (const issue of entrypoints.issues) {
59
+ if (issue.severity === "error" || issue.severity === "fatal") {
60
+ topLevelErrors.push((0, util_1.formatIssue)(issue));
61
+ }
62
+ else if ((0, util_1.isRelevantWarning)(issue)) {
63
+ topLevelWarnings.push((0, util_1.formatIssue)(issue));
64
+ }
65
+ }
66
+ if (topLevelWarnings.length > 0) {
67
+ console.warn(`Turbopack build encountered ${topLevelWarnings.length} warnings:\n${topLevelWarnings.join("\n")}`);
68
+ }
69
+ if (topLevelErrors.length > 0) {
70
+ throw new Error(`Turbopack build failed with ${topLevelErrors.length} errors:\n${topLevelErrors.join("\n")}`);
71
+ }
72
+ await project.shutdown();
73
+ // TODO: Maybe run tasks in worker is a better way, see
74
+ // https://github.com/vercel/next.js/blob/512d8283054407ab92b2583ecce3b253c3be7b85/packages/next/src/lib/worker.ts
75
+ }
@@ -0,0 +1,2 @@
1
+ export declare function decodeMagicIdentifier(identifier: string): string;
2
+ export declare const MAGIC_IDENTIFIER_REGEX: RegExp;