@workflow/next 4.0.1-beta.0 → 4.0.1-beta.10
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/LICENSE.md +201 -21
- package/dist/builder.d.ts +11 -0
- package/dist/builder.d.ts.map +1 -0
- package/dist/builder.js +320 -0
- package/dist/builder.js.map +1 -0
- package/dist/index.d.ts +6 -120
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -48
- package/dist/index.js.map +1 -1
- package/dist/loader.d.ts +1 -1
- package/dist/loader.d.ts.map +1 -1
- package/dist/loader.js +38 -3
- package/dist/loader.js.map +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +1 -1
- package/dist/runtime.js.map +1 -1
- package/package.json +18 -7
package/LICENSE.md
CHANGED
|
@@ -1,21 +1,201 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
<http://www.apache.org/licenses/>
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Vercel Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseBuilder } from '@workflow/builders';
|
|
2
|
+
export declare class NextBuilder extends BaseBuilder {
|
|
3
|
+
build(): Promise<void>;
|
|
4
|
+
protected getInputFiles(): Promise<string[]>;
|
|
5
|
+
private writeFunctionsConfig;
|
|
6
|
+
private buildStepsFunction;
|
|
7
|
+
private buildWorkflowsFunction;
|
|
8
|
+
private buildWebhookRoute;
|
|
9
|
+
private findAppDirectory;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,WAAW,EAGZ,MAAM,oBAAoB,CAAC;AAE5B,qBAAa,WAAY,SAAQ,WAAW;IACpC,KAAK;cAsTK,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YAUpC,oBAAoB;YAuBpB,kBAAkB;YA6BlB,sBAAsB;YA0BtB,iBAAiB;YAejB,gBAAgB;CA0B/B"}
|
package/dist/builder.js
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
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.NextBuilder = void 0;
|
|
7
|
+
const node_fs_1 = require("node:fs");
|
|
8
|
+
const promises_1 = require("node:fs/promises");
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
const watchpack_1 = __importDefault(require("watchpack"));
|
|
11
|
+
const builders_1 = require("@workflow/builders");
|
|
12
|
+
class NextBuilder extends builders_1.BaseBuilder {
|
|
13
|
+
async build() {
|
|
14
|
+
const outputDir = await this.findAppDirectory();
|
|
15
|
+
const workflowGeneratedDir = (0, node_path_1.join)(outputDir, '.well-known/workflow/v1');
|
|
16
|
+
// Ensure output directories exist
|
|
17
|
+
await (0, promises_1.mkdir)(workflowGeneratedDir, { recursive: true });
|
|
18
|
+
// ignore the generated assets
|
|
19
|
+
await (0, promises_1.writeFile)((0, node_path_1.join)(workflowGeneratedDir, '.gitignore'), '*');
|
|
20
|
+
const inputFiles = await this.getInputFiles();
|
|
21
|
+
const tsConfig = await this.getTsConfigOptions();
|
|
22
|
+
const options = {
|
|
23
|
+
inputFiles,
|
|
24
|
+
workflowGeneratedDir,
|
|
25
|
+
tsBaseUrl: tsConfig.baseUrl,
|
|
26
|
+
tsPaths: tsConfig.paths,
|
|
27
|
+
};
|
|
28
|
+
const stepsBuildContext = await this.buildStepsFunction(options);
|
|
29
|
+
const workflowsBundle = await this.buildWorkflowsFunction(options);
|
|
30
|
+
await this.buildWebhookRoute({ workflowGeneratedDir });
|
|
31
|
+
await this.writeFunctionsConfig(outputDir);
|
|
32
|
+
if (this.config.watch) {
|
|
33
|
+
if (!stepsBuildContext) {
|
|
34
|
+
throw new Error('Invariant: expected steps build context in watch mode');
|
|
35
|
+
}
|
|
36
|
+
if (!workflowsBundle) {
|
|
37
|
+
throw new Error('Invariant: expected workflows bundle in watch mode');
|
|
38
|
+
}
|
|
39
|
+
let stepsCtx = stepsBuildContext;
|
|
40
|
+
let workflowsCtx = workflowsBundle;
|
|
41
|
+
const normalizePath = (pathname) => pathname.replace(/\\/g, '/');
|
|
42
|
+
const knownFiles = new Set();
|
|
43
|
+
let previousTimeInfo = new Map();
|
|
44
|
+
const watchableExtensions = new Set([
|
|
45
|
+
'.js',
|
|
46
|
+
'.jsx',
|
|
47
|
+
'.ts',
|
|
48
|
+
'.tsx',
|
|
49
|
+
'.mts',
|
|
50
|
+
'.cjs',
|
|
51
|
+
'.mjs',
|
|
52
|
+
]);
|
|
53
|
+
const ignoredPathFragments = [
|
|
54
|
+
'/.git/',
|
|
55
|
+
'/node_modules/',
|
|
56
|
+
'/.next/',
|
|
57
|
+
'/.turbo/',
|
|
58
|
+
'/.vercel/',
|
|
59
|
+
'/dist/',
|
|
60
|
+
'/build/',
|
|
61
|
+
'/out/',
|
|
62
|
+
'/.cache/',
|
|
63
|
+
'/.yarn/',
|
|
64
|
+
'/.pnpm-store/',
|
|
65
|
+
'/.parcel-cache/',
|
|
66
|
+
'/.well-known/workflow/',
|
|
67
|
+
];
|
|
68
|
+
const normalizedGeneratedDir = workflowGeneratedDir.replace(/\\/g, '/');
|
|
69
|
+
ignoredPathFragments.push(normalizedGeneratedDir);
|
|
70
|
+
// There is a node.js bug on MacOS which causes closing file watchers to be really slow.
|
|
71
|
+
// This limits the number of watchers to mitigate the issue.
|
|
72
|
+
// https://github.com/nodejs/node/issues/29949
|
|
73
|
+
process.env.WATCHPACK_WATCHER_LIMIT =
|
|
74
|
+
process.platform === 'darwin' ? '20' : undefined;
|
|
75
|
+
const watcher = new watchpack_1.default({
|
|
76
|
+
// Watchpack default is 200ms which adds 200ms of dead time on bootup.
|
|
77
|
+
aggregateTimeout: 5,
|
|
78
|
+
ignored: (pathname) => {
|
|
79
|
+
const normalizedPath = pathname.replace(/\\/g, '/');
|
|
80
|
+
const extension = (0, node_path_1.extname)(normalizedPath);
|
|
81
|
+
if (extension && !watchableExtensions.has(extension)) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
if (normalizedPath.startsWith(normalizedGeneratedDir)) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
for (const fragment of ignoredPathFragments) {
|
|
88
|
+
if (normalizedPath.includes(fragment)) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return false;
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
const readTimeInfoEntries = () => {
|
|
96
|
+
const rawEntries = watcher.getTimeInfoEntries();
|
|
97
|
+
const normalizedEntries = new Map();
|
|
98
|
+
for (const [path, info] of rawEntries) {
|
|
99
|
+
normalizedEntries.set(normalizePath(path), info);
|
|
100
|
+
}
|
|
101
|
+
return normalizedEntries;
|
|
102
|
+
};
|
|
103
|
+
let rebuildQueue = Promise.resolve();
|
|
104
|
+
const enqueue = (task) => {
|
|
105
|
+
rebuildQueue = rebuildQueue.then(task).catch((error) => {
|
|
106
|
+
console.error('Failed to process file change', error);
|
|
107
|
+
});
|
|
108
|
+
return rebuildQueue;
|
|
109
|
+
};
|
|
110
|
+
const fullRebuild = async () => {
|
|
111
|
+
const newInputFiles = await this.getInputFiles();
|
|
112
|
+
options.inputFiles = newInputFiles;
|
|
113
|
+
await stepsCtx.dispose();
|
|
114
|
+
const newStepsCtx = await this.buildStepsFunction(options);
|
|
115
|
+
if (!newStepsCtx) {
|
|
116
|
+
throw new Error('Invariant: expected steps build context after rebuild');
|
|
117
|
+
}
|
|
118
|
+
stepsCtx = newStepsCtx;
|
|
119
|
+
await workflowsCtx.interimBundleCtx.dispose();
|
|
120
|
+
const newWorkflowsCtx = await this.buildWorkflowsFunction(options);
|
|
121
|
+
if (!newWorkflowsCtx) {
|
|
122
|
+
throw new Error('Invariant: expected workflows bundle context after rebuild');
|
|
123
|
+
}
|
|
124
|
+
workflowsCtx = newWorkflowsCtx;
|
|
125
|
+
};
|
|
126
|
+
const logBuildMessages = (result, label) => {
|
|
127
|
+
const logByType = (messages, method) => {
|
|
128
|
+
if (!messages || messages.length === 0) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const descriptor = method === 'error' ? 'errors' : 'warnings';
|
|
132
|
+
console[method](`${descriptor} while rebuilding ${label}`);
|
|
133
|
+
for (const message of messages) {
|
|
134
|
+
console[method](message);
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
logByType(result.errors, 'error');
|
|
138
|
+
logByType(result.warnings, 'warn');
|
|
139
|
+
};
|
|
140
|
+
const rebuildExistingFiles = async () => {
|
|
141
|
+
const rebuiltStepStart = Date.now();
|
|
142
|
+
const stepsResult = await stepsCtx.rebuild();
|
|
143
|
+
logBuildMessages(stepsResult, 'steps bundle');
|
|
144
|
+
console.log('Rebuilt steps bundle', `${Date.now() - rebuiltStepStart}ms`);
|
|
145
|
+
const rebuiltWorkflowStart = Date.now();
|
|
146
|
+
const workflowResult = await workflowsCtx.interimBundleCtx.rebuild();
|
|
147
|
+
logBuildMessages(workflowResult, 'workflows bundle');
|
|
148
|
+
if (!workflowResult.outputFiles ||
|
|
149
|
+
workflowResult.outputFiles.length === 0) {
|
|
150
|
+
console.error('No output generated while rebuilding workflows bundle');
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
await workflowsCtx.bundleFinal(workflowResult.outputFiles[0].text);
|
|
154
|
+
console.log('Rebuilt workflow bundle', `${Date.now() - rebuiltWorkflowStart}ms`);
|
|
155
|
+
};
|
|
156
|
+
const isWatchableFile = (path) => watchableExtensions.has((0, node_path_1.extname)(path));
|
|
157
|
+
const getComparableTimestamp = (entry) => entry.timestamp ?? entry.safeTime;
|
|
158
|
+
const findRemovedFiles = (currentEntries, previousEntries) => {
|
|
159
|
+
const removed = [];
|
|
160
|
+
for (const path of previousEntries.keys()) {
|
|
161
|
+
if (!currentEntries.has(path) && isWatchableFile(path)) {
|
|
162
|
+
removed.push(path);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return removed;
|
|
166
|
+
};
|
|
167
|
+
const findAddedAndModifiedFiles = (currentEntries, previousEntries) => {
|
|
168
|
+
const added = [];
|
|
169
|
+
const modified = [];
|
|
170
|
+
for (const [path, info] of currentEntries) {
|
|
171
|
+
if (!isWatchableFile(path)) {
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const previous = previousEntries.get(path);
|
|
175
|
+
if (!previous) {
|
|
176
|
+
added.push(path);
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (getComparableTimestamp(info) !== getComparableTimestamp(previous)) {
|
|
180
|
+
modified.push(path);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return { added, modified };
|
|
184
|
+
};
|
|
185
|
+
const determineFileChanges = (currentEntries, previousEntries) => {
|
|
186
|
+
const removedFiles = findRemovedFiles(currentEntries, previousEntries);
|
|
187
|
+
const { added, modified } = findAddedAndModifiedFiles(currentEntries, previousEntries);
|
|
188
|
+
return {
|
|
189
|
+
addedFiles: added,
|
|
190
|
+
modifiedFiles: modified,
|
|
191
|
+
removedFiles,
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
let isInitial = true;
|
|
195
|
+
watcher.on('aggregated', () => {
|
|
196
|
+
const currentEntries = readTimeInfoEntries();
|
|
197
|
+
const { addedFiles, modifiedFiles, removedFiles } = determineFileChanges(currentEntries, previousTimeInfo);
|
|
198
|
+
previousTimeInfo = currentEntries;
|
|
199
|
+
if (isInitial) {
|
|
200
|
+
isInitial = false;
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (addedFiles.length === 0 &&
|
|
204
|
+
modifiedFiles.length === 0 &&
|
|
205
|
+
removedFiles.length === 0) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
for (const removal of removedFiles) {
|
|
209
|
+
knownFiles.delete(removal);
|
|
210
|
+
}
|
|
211
|
+
for (const added of addedFiles) {
|
|
212
|
+
knownFiles.add(added);
|
|
213
|
+
}
|
|
214
|
+
enqueue(async () => {
|
|
215
|
+
if (addedFiles.length > 0 || removedFiles.length > 0) {
|
|
216
|
+
await fullRebuild();
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (modifiedFiles.length > 0) {
|
|
220
|
+
await rebuildExistingFiles();
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
watcher.watch({
|
|
225
|
+
directories: [this.config.workingDir],
|
|
226
|
+
startTime: 0,
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
async getInputFiles() {
|
|
231
|
+
const inputFiles = await super.getInputFiles();
|
|
232
|
+
return inputFiles.filter((item) =>
|
|
233
|
+
// non-exact pattern match to try to narrow
|
|
234
|
+
// down to just app route entrypoints, this will
|
|
235
|
+
// not be valid when pages router support is added
|
|
236
|
+
item.match(/[/\\](route|page|layout)\./));
|
|
237
|
+
}
|
|
238
|
+
async writeFunctionsConfig(outputDir) {
|
|
239
|
+
// we don't run this in development mode as it's not needed
|
|
240
|
+
if (process.env.NODE_ENV === 'development') {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
const generatedConfig = {
|
|
244
|
+
version: '0',
|
|
245
|
+
steps: {
|
|
246
|
+
experimentalTriggers: [builders_1.STEP_QUEUE_TRIGGER],
|
|
247
|
+
},
|
|
248
|
+
workflows: {
|
|
249
|
+
experimentalTriggers: [builders_1.WORKFLOW_QUEUE_TRIGGER],
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
// We write this file to the generated directory for
|
|
253
|
+
// the Next.js builder to consume
|
|
254
|
+
await (0, promises_1.writeFile)((0, node_path_1.join)(outputDir, '.well-known/workflow/v1/config.json'), JSON.stringify(generatedConfig, null, 2));
|
|
255
|
+
}
|
|
256
|
+
async buildStepsFunction({ inputFiles, workflowGeneratedDir, tsPaths, tsBaseUrl, }) {
|
|
257
|
+
// Create steps bundle
|
|
258
|
+
const stepsRouteDir = (0, node_path_1.join)(workflowGeneratedDir, 'step');
|
|
259
|
+
await (0, promises_1.mkdir)(stepsRouteDir, { recursive: true });
|
|
260
|
+
return await this.createStepsBundle({
|
|
261
|
+
// If any dynamic requires are used when bundling with ESM
|
|
262
|
+
// esbuild will create a too dynamic wrapper around require
|
|
263
|
+
// which turbopack/webpack fail to analyze. If we externalize
|
|
264
|
+
// correctly this shouldn't be an issue although we might want
|
|
265
|
+
// to use cjs as alternative to avoid
|
|
266
|
+
format: 'esm',
|
|
267
|
+
inputFiles,
|
|
268
|
+
outfile: (0, node_path_1.join)(stepsRouteDir, 'route.js'),
|
|
269
|
+
externalizeNonSteps: true,
|
|
270
|
+
tsBaseUrl,
|
|
271
|
+
tsPaths,
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
async buildWorkflowsFunction({ inputFiles, workflowGeneratedDir, tsPaths, tsBaseUrl, }) {
|
|
275
|
+
const workflowsRouteDir = (0, node_path_1.join)(workflowGeneratedDir, 'flow');
|
|
276
|
+
await (0, promises_1.mkdir)(workflowsRouteDir, { recursive: true });
|
|
277
|
+
return await this.createWorkflowsBundle({
|
|
278
|
+
format: 'esm',
|
|
279
|
+
outfile: (0, node_path_1.join)(workflowsRouteDir, 'route.js'),
|
|
280
|
+
bundleFinalOutput: false,
|
|
281
|
+
inputFiles,
|
|
282
|
+
tsBaseUrl,
|
|
283
|
+
tsPaths,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
async buildWebhookRoute({ workflowGeneratedDir, }) {
|
|
287
|
+
const webhookRouteFile = (0, node_path_1.join)(workflowGeneratedDir, 'webhook/[token]/route.js');
|
|
288
|
+
await this.createWebhookBundle({
|
|
289
|
+
outfile: webhookRouteFile,
|
|
290
|
+
bundle: false, // Next.js doesn't need bundling
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
async findAppDirectory() {
|
|
294
|
+
const appDir = (0, node_path_1.resolve)(this.config.workingDir, 'app');
|
|
295
|
+
const srcAppDir = (0, node_path_1.resolve)(this.config.workingDir, 'src/app');
|
|
296
|
+
try {
|
|
297
|
+
await (0, promises_1.access)(appDir, node_fs_1.constants.F_OK);
|
|
298
|
+
const appStats = await (0, promises_1.stat)(appDir);
|
|
299
|
+
if (!appStats.isDirectory()) {
|
|
300
|
+
throw new Error(`Path exists but is not a directory: ${appDir}`);
|
|
301
|
+
}
|
|
302
|
+
return appDir;
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
try {
|
|
306
|
+
await (0, promises_1.access)(srcAppDir, node_fs_1.constants.F_OK);
|
|
307
|
+
const srcAppStats = await (0, promises_1.stat)(srcAppDir);
|
|
308
|
+
if (!srcAppStats.isDirectory()) {
|
|
309
|
+
throw new Error(`Path exists but is not a directory: ${srcAppDir}`);
|
|
310
|
+
}
|
|
311
|
+
return srcAppDir;
|
|
312
|
+
}
|
|
313
|
+
catch {
|
|
314
|
+
throw new Error('Could not find Next.js app directory. Expected either "app" or "src/app" to exist.');
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
exports.NextBuilder = NextBuilder;
|
|
320
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAoC;AACpC,+CAAkE;AAClE,yCAAmD;AACnD,0DAAkC;AAClC,iDAI4B;AAE5B,MAAa,WAAY,SAAQ,sBAAW;IAC1C,KAAK,CAAC,KAAK;QACT,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAChD,MAAM,oBAAoB,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,yBAAyB,CAAC,CAAC;QAExE,kCAAkC;QAClC,MAAM,IAAA,gBAAK,EAAC,oBAAoB,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACvD,8BAA8B;QAE9B,MAAM,IAAA,oBAAS,EAAC,IAAA,gBAAI,EAAC,oBAAoB,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,CAAC;QAE/D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,kBAAkB,EAAE,CAAC;QAEjD,MAAM,OAAO,GAAG;YACd,UAAU;YACV,oBAAoB;YACpB,SAAS,EAAE,QAAQ,CAAC,OAAO;YAC3B,OAAO,EAAE,QAAQ,CAAC,KAAK;SACxB,CAAC;QAEF,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;QACjE,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,sBAAsB,CAAC,OAAO,CAAC,CAAC;QACnE,MAAM,IAAI,CAAC,iBAAiB,CAAC,EAAE,oBAAoB,EAAE,CAAC,CAAC;QACvD,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;QAE3C,IAAI,IA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AAC,CAAC;IACL,CAAC;IAEO,KAAK,CAAC,gBAAgB;QAC5B,MAAM,MAAM,GAAG,IAAA,mBAAO,EAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QACtD,MAAM,SAAS,GAAG,IAAA,mBAAO,EAAC,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAE7D,IAAI,CAAC;YACH,MAAM,IAAA,iBAAM,EAAC,MAAM,EAAE,mBAAS,CAAC,IAAI,CAAC,CAAC;YACrC,MAAM,QAAQ,GAAG,MAAM,IAAA,eAAI,EAAC,MAAM,CAAC,CAAC;YACpC,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC5B,MAAM,IAAI,KAAK,CAAC,uCAAuC,MAAM,EAAE,CAAC,CAAC;YACnE,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC;gBACH,MAAM,IAAA,iBAAM,EAAC,SAAS,EAAE,mBAAS,CAAC,IAAI,CAAC,CAAC;gBACxC,MAAM,WAAW,GAAG,MAAM,IAAA,eAAI,EAAC,SAAS,CAAC,CAAC;gBAC1C,IAAI,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC;oBAC/B,MAAM,IAAI,KAAK,CAAC,uCAAuC,SAAS,EAAE,CAAC,CAAC;gBACtE,CAAC;gBACD,OAAO,SAAS,CAAC;YACnB,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,IAAI,KAAK,CACb,oFAAoF,CACrF,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;CACF;AAxbD,kCAwbC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,128 +1,14 @@
|
|
|
1
1
|
import type { NextConfig } from 'next';
|
|
2
|
-
export declare function withWorkflow(
|
|
2
|
+
export declare function withWorkflow(nextConfigOrFn: NextConfig | ((phase: string, ctx: {
|
|
3
|
+
defaultConfig: NextConfig;
|
|
4
|
+
}) => Promise<NextConfig>), { workflows, }?: {
|
|
3
5
|
workflows?: {
|
|
4
6
|
embedded?: {
|
|
5
7
|
port?: number;
|
|
6
8
|
dataDir?: string;
|
|
7
9
|
};
|
|
8
10
|
};
|
|
9
|
-
}): (phase: string
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exportPathMap?: (defaultMap: import("next/dist/server/config-shared").ExportPathMap, ctx: {
|
|
13
|
-
dev: boolean;
|
|
14
|
-
dir: string;
|
|
15
|
-
outDir: string | null;
|
|
16
|
-
distDir: string;
|
|
17
|
-
buildId: string;
|
|
18
|
-
}) => Promise<import("next/dist/server/config-shared").ExportPathMap> | import("next/dist/server/config-shared").ExportPathMap;
|
|
19
|
-
i18n?: import("next/dist/server/config-shared").I18NConfig | null;
|
|
20
|
-
eslint?: import("next/dist/server/config-shared").ESLintConfig;
|
|
21
|
-
typescript?: import("next/dist/server/config-shared").TypeScriptConfig;
|
|
22
|
-
typedRoutes?: boolean;
|
|
23
|
-
headers?: () => Promise<import("next/dist/lib/load-custom-routes").Header[]>;
|
|
24
|
-
rewrites?: () => Promise<import("next/dist/lib/load-custom-routes").Rewrite[] | {
|
|
25
|
-
beforeFiles?: import("next/dist/lib/load-custom-routes").Rewrite[];
|
|
26
|
-
afterFiles?: import("next/dist/lib/load-custom-routes").Rewrite[];
|
|
27
|
-
fallback?: import("next/dist/lib/load-custom-routes").Rewrite[];
|
|
28
|
-
}>;
|
|
29
|
-
redirects?: () => Promise<import("next/dist/lib/load-custom-routes").Redirect[]>;
|
|
30
|
-
excludeDefaultMomentLocales?: boolean;
|
|
31
|
-
webpack?: import("next/dist/server/config-shared").NextJsWebpackConfig | null;
|
|
32
|
-
trailingSlash?: boolean;
|
|
33
|
-
env?: Record<string, string | undefined>;
|
|
34
|
-
distDir?: string;
|
|
35
|
-
cleanDistDir?: boolean;
|
|
36
|
-
assetPrefix?: string;
|
|
37
|
-
cacheHandler?: string | undefined;
|
|
38
|
-
cacheMaxMemorySize?: number;
|
|
39
|
-
useFileSystemPublicRoutes?: boolean;
|
|
40
|
-
generateBuildId?: () => string | null | Promise<string | null>;
|
|
41
|
-
generateEtags?: boolean;
|
|
42
|
-
pageExtensions?: string[];
|
|
43
|
-
compress?: boolean;
|
|
44
|
-
poweredByHeader?: boolean;
|
|
45
|
-
images?: import("next/dist/shared/lib/image-config").ImageConfig;
|
|
46
|
-
devIndicators?: false | {
|
|
47
|
-
appIsrStatus?: boolean;
|
|
48
|
-
buildActivity?: boolean;
|
|
49
|
-
buildActivityPosition?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
50
|
-
position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
|
|
51
|
-
};
|
|
52
|
-
onDemandEntries?: {
|
|
53
|
-
maxInactiveAge?: number;
|
|
54
|
-
pagesBufferLength?: number;
|
|
55
|
-
};
|
|
56
|
-
amp?: {
|
|
57
|
-
canonicalBase?: string;
|
|
58
|
-
};
|
|
59
|
-
deploymentId?: string;
|
|
60
|
-
basePath?: string;
|
|
61
|
-
sassOptions?: {
|
|
62
|
-
implementation?: string;
|
|
63
|
-
[key: string]: any;
|
|
64
|
-
};
|
|
65
|
-
productionBrowserSourceMaps?: boolean;
|
|
66
|
-
reactProductionProfiling?: boolean;
|
|
67
|
-
reactStrictMode?: boolean | null;
|
|
68
|
-
reactMaxHeadersLength?: number;
|
|
69
|
-
publicRuntimeConfig?: {
|
|
70
|
-
[key: string]: any;
|
|
71
|
-
};
|
|
72
|
-
serverRuntimeConfig?: {
|
|
73
|
-
[key: string]: any;
|
|
74
|
-
};
|
|
75
|
-
httpAgentOptions?: {
|
|
76
|
-
keepAlive?: boolean;
|
|
77
|
-
};
|
|
78
|
-
staticPageGenerationTimeout?: number;
|
|
79
|
-
crossOrigin?: "anonymous" | "use-credentials";
|
|
80
|
-
compiler?: {
|
|
81
|
-
reactRemoveProperties?: boolean | {
|
|
82
|
-
properties?: string[];
|
|
83
|
-
};
|
|
84
|
-
relay?: {
|
|
85
|
-
src: string;
|
|
86
|
-
artifactDirectory?: string;
|
|
87
|
-
language?: "typescript" | "javascript" | "flow";
|
|
88
|
-
eagerEsModules?: boolean;
|
|
89
|
-
};
|
|
90
|
-
removeConsole?: boolean | {
|
|
91
|
-
exclude?: string[];
|
|
92
|
-
};
|
|
93
|
-
styledComponents?: boolean | import("next/dist/server/config-shared").StyledComponentsConfig;
|
|
94
|
-
emotion?: boolean | import("next/dist/server/config-shared").EmotionConfig;
|
|
95
|
-
styledJsx?: boolean | {
|
|
96
|
-
useLightningcss?: boolean;
|
|
97
|
-
};
|
|
98
|
-
define?: Record<string, string>;
|
|
99
|
-
defineServer?: Record<string, string>;
|
|
100
|
-
runAfterProductionCompile?: (metadata: {
|
|
101
|
-
projectDir: string;
|
|
102
|
-
distDir: string;
|
|
103
|
-
}) => Promise<void>;
|
|
104
|
-
};
|
|
105
|
-
output?: "standalone" | "export";
|
|
106
|
-
transpilePackages?: string[];
|
|
107
|
-
turbopack?: import("next/dist/server/config-shared").TurbopackOptions;
|
|
108
|
-
skipMiddlewareUrlNormalize?: boolean;
|
|
109
|
-
skipTrailingSlashRedirect?: boolean;
|
|
110
|
-
modularizeImports?: Record<string, {
|
|
111
|
-
transform: string | Record<string, string>;
|
|
112
|
-
preventFullImport?: boolean;
|
|
113
|
-
skipDefaultConversion?: boolean;
|
|
114
|
-
}>;
|
|
115
|
-
logging?: import("next/dist/server/config-shared").LoggingConfig | false;
|
|
116
|
-
expireTime?: number;
|
|
117
|
-
experimental?: import("next/dist/server/config-shared").ExperimentalConfig;
|
|
118
|
-
bundlePagesRouterDependencies?: boolean;
|
|
119
|
-
serverExternalPackages?: string[];
|
|
120
|
-
outputFileTracingRoot?: string;
|
|
121
|
-
outputFileTracingExcludes?: Record<string, string[]>;
|
|
122
|
-
outputFileTracingIncludes?: Record<string, string[]>;
|
|
123
|
-
watchOptions?: {
|
|
124
|
-
pollIntervalMs?: number;
|
|
125
|
-
};
|
|
126
|
-
htmlLimitedBots?: RegExp;
|
|
127
|
-
}>;
|
|
11
|
+
}): (phase: string, ctx: {
|
|
12
|
+
defaultConfig: NextConfig;
|
|
13
|
+
}) => Promise<NextConfig>;
|
|
128
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAGvC,wBAAgB,YAAY,CAC1B,cAAc,EACV,UAAU,GACV,CAAC,CACC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE;IAAE,aAAa,EAAE,UAAU,CAAA;CAAE,KAC/B,OAAO,CAAC,UAAU,CAAC,CAAC,EAC7B,EACE,SAAS,GACV,GAAE;IACD,SAAS,CAAC,EAAE;QACV,QAAQ,CAAC,EAAE;YACT,IAAI,CAAC,EAAE,MAAM,CAAC;YACd,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;KACH,CAAC;CACE,IAkBJ,OAAO,MAAM,EACb,KAAK;IAAE,aAAa,EAAE,UAAU,CAAA;CAAE,yBA6FrC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.withWorkflow = withWorkflow;
|
|
4
|
-
const
|
|
5
|
-
|
|
7
|
+
const builder_js_1 = require("./builder.js");
|
|
8
|
+
const semver_1 = __importDefault(require("semver"));
|
|
9
|
+
function withWorkflow(nextConfigOrFn, { workflows, } = {}) {
|
|
6
10
|
if (!process.env.VERCEL_DEPLOYMENT_ID) {
|
|
7
11
|
if (!process.env.WORKFLOW_TARGET_WORLD) {
|
|
8
12
|
process.env.WORKFLOW_TARGET_WORLD = 'embedded';
|
|
@@ -18,64 +22,79 @@ function withWorkflow({ workflows, ...nextConfig }) {
|
|
|
18
22
|
process.env.WORKFLOW_TARGET_WORLD = 'vercel';
|
|
19
23
|
}
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!nextConfig.turbopack.rules) {
|
|
27
|
-
nextConfig.turbopack.rules = {};
|
|
28
|
-
}
|
|
29
|
-
const existingRules = nextConfig.turbopack.rules;
|
|
30
|
-
nextConfig.turbopack.rules = {
|
|
31
|
-
...existingRules,
|
|
32
|
-
'*.tsx': {
|
|
33
|
-
loaders: [...(existingRules['*.tsx']?.loaders || []), loaderPath],
|
|
34
|
-
},
|
|
35
|
-
'*.ts': {
|
|
36
|
-
loaders: [...(existingRules['*.ts']?.loaders || []), loaderPath],
|
|
37
|
-
},
|
|
38
|
-
'*.jsx': {
|
|
39
|
-
loaders: [...(existingRules['*.jsx']?.loaders || []), loaderPath],
|
|
40
|
-
},
|
|
41
|
-
'*.js': {
|
|
42
|
-
loaders: [...(existingRules['*.js']?.loaders || []), loaderPath],
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
// configure the loader for webpack
|
|
46
|
-
const existingWebpackModify = nextConfig.webpack;
|
|
47
|
-
nextConfig.webpack = (...args) => {
|
|
48
|
-
const [webpackConfig] = args;
|
|
49
|
-
if (!webpackConfig.module) {
|
|
50
|
-
webpackConfig.module = {};
|
|
25
|
+
return async function buildConfig(phase, ctx) {
|
|
26
|
+
const loaderPath = require.resolve('./loader');
|
|
27
|
+
let nextConfig;
|
|
28
|
+
if (typeof nextConfigOrFn === 'function') {
|
|
29
|
+
nextConfig = await nextConfigOrFn(phase, ctx);
|
|
51
30
|
}
|
|
52
|
-
|
|
53
|
-
|
|
31
|
+
else {
|
|
32
|
+
nextConfig = nextConfigOrFn;
|
|
54
33
|
}
|
|
55
|
-
//
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
34
|
+
// shallow clone to avoid read-only on top-level
|
|
35
|
+
nextConfig = Object.assign({}, nextConfig);
|
|
36
|
+
// configure the loader if turbopack is being used
|
|
37
|
+
if (!nextConfig.turbopack) {
|
|
38
|
+
nextConfig.turbopack = {};
|
|
39
|
+
}
|
|
40
|
+
if (!nextConfig.turbopack.rules) {
|
|
41
|
+
nextConfig.turbopack.rules = {};
|
|
42
|
+
}
|
|
43
|
+
const existingRules = nextConfig.turbopack.rules;
|
|
44
|
+
const nextVersion = require('next/package.json').version;
|
|
45
|
+
const supportsTurboCondition = semver_1.default.gte(nextVersion, 'v16.0.0');
|
|
46
|
+
for (const key of ['*.tsx', '*.ts', '*.jsx', '*.js']) {
|
|
47
|
+
nextConfig.turbopack.rules[key] = {
|
|
48
|
+
...(supportsTurboCondition
|
|
49
|
+
? {
|
|
50
|
+
condition: {
|
|
51
|
+
...existingRules[key]?.condition,
|
|
52
|
+
any: [
|
|
53
|
+
...(existingRules[key]?.condition.any || []),
|
|
54
|
+
{
|
|
55
|
+
content: /(use workflow|use step)/,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
}
|
|
60
|
+
: {}),
|
|
61
|
+
loaders: [...(existingRules[key]?.loaders || []), loaderPath],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// configure the loader for webpack
|
|
65
|
+
const existingWebpackModify = nextConfig.webpack;
|
|
66
|
+
nextConfig.webpack = (...args) => {
|
|
67
|
+
const [webpackConfig] = args;
|
|
68
|
+
if (!webpackConfig.module) {
|
|
69
|
+
webpackConfig.module = {};
|
|
70
|
+
}
|
|
71
|
+
if (!webpackConfig.module.rules) {
|
|
72
|
+
webpackConfig.module.rules = [];
|
|
73
|
+
}
|
|
74
|
+
// loaders in webpack apply bottom->up so ensure
|
|
75
|
+
// ours comes before the default swc transform
|
|
76
|
+
webpackConfig.module.rules.push({
|
|
77
|
+
test: /.*\.(mjs|cjs|cts|ts|tsx|js|jsx)$/,
|
|
78
|
+
loader: loaderPath,
|
|
79
|
+
});
|
|
80
|
+
return existingWebpackModify
|
|
81
|
+
? existingWebpackModify(...args)
|
|
82
|
+
: webpackConfig;
|
|
83
|
+
};
|
|
66
84
|
// only run this in the main process so it only runs once
|
|
67
85
|
// as Next.js uses child processes for different builds
|
|
68
86
|
if (!process.env.WORKFLOW_NEXT_PRIVATE_BUILT &&
|
|
69
87
|
phase !== 'phase-production-server') {
|
|
70
88
|
const shouldWatch = process.env.NODE_ENV === 'development';
|
|
71
|
-
const workflowBuilder = new
|
|
89
|
+
const workflowBuilder = new builder_js_1.NextBuilder({
|
|
72
90
|
watch: shouldWatch,
|
|
73
91
|
// discover workflows from pages/app entries
|
|
74
92
|
dirs: ['pages', 'app', 'src/pages', 'src/app'],
|
|
75
93
|
workingDir: process.cwd(),
|
|
76
94
|
buildTarget: 'next',
|
|
77
|
-
workflowsBundlePath: '',
|
|
78
|
-
stepsBundlePath: '',
|
|
95
|
+
workflowsBundlePath: '', // not used in base
|
|
96
|
+
stepsBundlePath: '', // not used in base
|
|
97
|
+
webhookBundlePath: '', // node used in base
|
|
79
98
|
externalPackages: [
|
|
80
99
|
...require('next/dist/lib/server-external-packages.json'),
|
|
81
100
|
...(nextConfig.serverExternalPackages || []),
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAIA,oCAgIC;AApID,6CAA2C;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.ts
CHANGED
package/dist/loader.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":"AAKA,wBAA8B,cAAc,CAC1C,IAAI,EAAE;IACJ,YAAY,EAAE,MAAM,CAAC;CACtB,EACD,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,SAAS,EAAE,GAAG,GACb,OAAO,CAAC,MAAM,CAAC,CAyEjB"}
|
package/dist/loader.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.default = workflowLoader;
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
4
5
|
const core_1 = require("@swc/core");
|
|
5
6
|
// This loader applies the "use workflow"/"use step"
|
|
6
7
|
// client transformation
|
|
7
|
-
function workflowLoader(source, sourceMap) {
|
|
8
|
+
async function workflowLoader(source, sourceMap) {
|
|
8
9
|
const filename = this.resourcePath;
|
|
9
10
|
const normalizedSource = source.toString();
|
|
10
11
|
// only apply the transform if file needs it
|
|
@@ -13,9 +14,43 @@ function workflowLoader(source, sourceMap) {
|
|
|
13
14
|
}
|
|
14
15
|
const isTypeScript = filename.endsWith('.ts') || filename.endsWith('.tsx');
|
|
15
16
|
const isTsx = filename.endsWith('.tsx');
|
|
17
|
+
// Calculate relative filename for SWC plugin
|
|
18
|
+
// The SWC plugin uses filename to generate workflowId, so it must be relative
|
|
19
|
+
const workingDir = process.cwd();
|
|
20
|
+
const normalizedWorkingDir = workingDir
|
|
21
|
+
.replace(/\\/g, '/')
|
|
22
|
+
.replace(/\/$/, '');
|
|
23
|
+
const normalizedFilepath = filename.replace(/\\/g, '/');
|
|
24
|
+
// Windows fix: Use case-insensitive comparison to work around drive letter casing issues
|
|
25
|
+
const lowerWd = normalizedWorkingDir.toLowerCase();
|
|
26
|
+
const lowerPath = normalizedFilepath.toLowerCase();
|
|
27
|
+
let relativeFilename;
|
|
28
|
+
if (lowerPath.startsWith(lowerWd + '/')) {
|
|
29
|
+
// File is under working directory - manually calculate relative path
|
|
30
|
+
relativeFilename = normalizedFilepath.substring(normalizedWorkingDir.length + 1);
|
|
31
|
+
}
|
|
32
|
+
else if (lowerPath === lowerWd) {
|
|
33
|
+
// File IS the working directory (shouldn't happen)
|
|
34
|
+
relativeFilename = '.';
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
// Use relative() for files outside working directory
|
|
38
|
+
relativeFilename = (0, node_path_1.relative)(workingDir, filename).replace(/\\/g, '/');
|
|
39
|
+
if (relativeFilename.startsWith('../')) {
|
|
40
|
+
relativeFilename = relativeFilename
|
|
41
|
+
.split('/')
|
|
42
|
+
.filter((part) => part !== '..')
|
|
43
|
+
.join('/');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
// Final safety check - ensure we never pass an absolute path to SWC
|
|
47
|
+
if (relativeFilename.includes(':') || relativeFilename.startsWith('/')) {
|
|
48
|
+
// This should rarely happen, but use filename split as last resort
|
|
49
|
+
relativeFilename = normalizedFilepath.split('/').pop() || 'unknown.ts';
|
|
50
|
+
}
|
|
16
51
|
// Transform with SWC
|
|
17
|
-
const result = (0, core_1.
|
|
18
|
-
filename,
|
|
52
|
+
const result = await (0, core_1.transform)(normalizedSource, {
|
|
53
|
+
filename: relativeFilename,
|
|
19
54
|
jsc: {
|
|
20
55
|
parser: {
|
|
21
56
|
syntax: isTypeScript ? 'typescript' : 'ecmascript',
|
package/dist/loader.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../src/loader.ts"],"names":[],"mappings":";;AAKA,iCA+EC;AApFD,yCA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rB,CAAC"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from '@workflow/
|
|
1
|
+
export * from '@workflow/core/dist/runtime';
|
|
2
2
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAGA,cAAc,
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAGA,cAAc,6BAA6B,CAAC"}
|
package/dist/runtime.js
CHANGED
|
@@ -17,5 +17,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
// re-export runtime as stub for resolving to not
|
|
18
18
|
// require @workflow/core be a dependency as well as
|
|
19
19
|
// @workflow/next
|
|
20
|
-
__exportStar(require("@workflow/
|
|
20
|
+
__exportStar(require("@workflow/core/dist/runtime"), exports);
|
|
21
21
|
//# sourceMappingURL=runtime.js.map
|
package/dist/runtime.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAAiD;AACjD,oDAAoD;AACpD,iBAAiB;AACjB,
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAAiD;AACjD,oDAAoD;AACpD,iBAAiB;AACjB,8DAA4C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workflow/next",
|
|
3
|
-
"version": "4.0.1-beta.
|
|
3
|
+
"version": "4.0.1-beta.10",
|
|
4
|
+
"description": "Next.js integration for Workflow DevKit",
|
|
4
5
|
"type": "commonjs",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"files": [
|
|
@@ -9,6 +10,12 @@
|
|
|
9
10
|
"publishConfig": {
|
|
10
11
|
"access": "public"
|
|
11
12
|
},
|
|
13
|
+
"license": "Apache-2.0",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/vercel/workflow.git",
|
|
17
|
+
"directory": "packages/next"
|
|
18
|
+
},
|
|
12
19
|
"exports": {
|
|
13
20
|
".": "./dist/index.js",
|
|
14
21
|
"./loader": "./dist/loader.js",
|
|
@@ -16,13 +23,17 @@
|
|
|
16
23
|
},
|
|
17
24
|
"dependencies": {
|
|
18
25
|
"@swc/core": "1.11.24",
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"@workflow/
|
|
26
|
+
"semver": "7.7.3",
|
|
27
|
+
"watchpack": "2.4.4",
|
|
28
|
+
"@workflow/builders": "4.0.1-beta.6",
|
|
29
|
+
"@workflow/core": "4.0.1-beta.8",
|
|
30
|
+
"@workflow/swc-plugin": "4.0.1-beta.3"
|
|
22
31
|
},
|
|
23
32
|
"devDependencies": {
|
|
24
|
-
"@types/node": "
|
|
25
|
-
"
|
|
33
|
+
"@types/node": "22.19.0",
|
|
34
|
+
"@types/semver": "7.7.1",
|
|
35
|
+
"@types/watchpack": "2.4.4",
|
|
36
|
+
"next": "16.0.1",
|
|
26
37
|
"@workflow/tsconfig": "4.0.1-beta.0"
|
|
27
38
|
},
|
|
28
39
|
"peerDependencies": {
|
|
@@ -36,6 +47,6 @@
|
|
|
36
47
|
"scripts": {
|
|
37
48
|
"build": "tsc",
|
|
38
49
|
"dev": "tsc --watch",
|
|
39
|
-
"clean": "tsc --build --clean"
|
|
50
|
+
"clean": "tsc --build --clean && rm -rf dist"
|
|
40
51
|
}
|
|
41
52
|
}
|