@serwist/turbopack 9.5.6 → 9.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/index.schema.js +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.schema.d.ts +4 -0
- package/dist/index.schema.d.ts.map +1 -1
- package/dist/types.d.ts +8 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -14
- package/src/index.schema.ts +1 -0
- package/src/index.ts +11 -2
- package/src/lib/utils.ts +3 -3
- package/src/types.ts +8 -1
|
@@ -121,7 +121,8 @@ const loadNextConfig = async (cwd, isDev)=>{
|
|
|
121
121
|
const nextPhase = isDev ? PHASE_DEVELOPMENT_SERVER : PHASE_PRODUCTION_BUILD;
|
|
122
122
|
// webpackIgnore is only supported by Next.js 15 and above, but it is necessary
|
|
123
123
|
const nextConfig = await import(/* webpackIgnore: true */ 'next/dist/server/config.js');
|
|
124
|
-
|
|
124
|
+
const loadConfig = typeof nextConfig.default === "function" ? nextConfig.default : nextConfig.default.default;
|
|
125
|
+
return loadConfig(nextPhase, cwd, {
|
|
125
126
|
silent: false
|
|
126
127
|
});
|
|
127
128
|
};
|
|
@@ -138,6 +139,7 @@ const turboPartial = z.strictObject({
|
|
|
138
139
|
distDir: z.string().optional()
|
|
139
140
|
}).optional(),
|
|
140
141
|
useNativeEsbuild: z.boolean().prefault(process.platform === "win32"),
|
|
142
|
+
rebuildOnChange: z.boolean().prefault(true),
|
|
141
143
|
esbuildOptions: z.partialRecord(z.literal(SUPPORTED_ESBUILD_OPTIONS), z.any()).prefault({})
|
|
142
144
|
});
|
|
143
145
|
const injectManifestOptions = z.strictObject({
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAK9C,OAAO,KAAK,EAAE,qBAAqB,EAAiC,MAAM,YAAY,CAAC;AAuCvF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,GAAI,SAAS,qBAAqB;;;;;;;aAoGzC,OAAO,cAAc;QAAE,MAAM,EAAE,OAAO,CAAC;YAAE,IAAI,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KAAE;CAmBjF,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,aAAY,UAAe,KAAG,UAGxD,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import fs from 'node:fs';
|
|
1
3
|
import path from 'node:path';
|
|
2
4
|
import { rebasePath, getFileManifestEntries } from '@serwist/build';
|
|
3
5
|
import { validationErrorMap, SerwistConfigError } from '@serwist/build/schema';
|
|
@@ -75,6 +77,7 @@ const createSerwistRoute = (options)=>{
|
|
|
75
77
|
]
|
|
76
78
|
};
|
|
77
79
|
});
|
|
80
|
+
let lastHash = null;
|
|
78
81
|
let map = null;
|
|
79
82
|
const loadMap = async (filePath)=>{
|
|
80
83
|
const config = await validation;
|
|
@@ -152,7 +155,14 @@ const createSerwistRoute = (options)=>{
|
|
|
152
155
|
const GET = async (_, { params })=>{
|
|
153
156
|
const { path: filePath } = await params;
|
|
154
157
|
const config = await validation;
|
|
155
|
-
if (
|
|
158
|
+
if (isDev && config.rebuildOnChange) {
|
|
159
|
+
const swContent = fs.readFileSync(config.swSrc, "utf-8");
|
|
160
|
+
const currentHash = crypto.createHash("sha256").update(swContent).digest("hex");
|
|
161
|
+
if (!map || lastHash !== currentHash) {
|
|
162
|
+
map = await loadMap(filePath);
|
|
163
|
+
lastHash = currentHash;
|
|
164
|
+
}
|
|
165
|
+
} else if (!map) map = await loadMap(filePath);
|
|
156
166
|
return new NextResponse(map.get(path.join(config.cwd, filePath)), {
|
|
157
167
|
headers: {
|
|
158
168
|
"Content-Type": contentTypeMap[path.extname(filePath)] || "text/plain",
|
package/dist/index.schema.d.ts
CHANGED
|
@@ -7,11 +7,13 @@ export declare const turboPartial: z.ZodObject<{
|
|
|
7
7
|
distDir: z.ZodOptional<z.ZodString>;
|
|
8
8
|
}, z.z.core.$strip>>;
|
|
9
9
|
useNativeEsbuild: z.ZodPrefault<z.ZodBoolean>;
|
|
10
|
+
rebuildOnChange: z.ZodPrefault<z.ZodBoolean>;
|
|
10
11
|
esbuildOptions: z.ZodPrefault<z.ZodRecord<z.ZodLiteral<"bundle" | "splitting" | "preserveSymlinks" | "external" | "packages" | "alias" | "loader" | "resolveExtensions" | "mainFields" | "conditions" | "allowOverwrite" | "tsconfig" | "outExtension" | "publicPath" | "inject" | "banner" | "footer" | "plugins" | "sourcemap" | "legalComments" | "sourceRoot" | "sourcesContent" | "format" | "globalName" | "target" | "supported" | "mangleProps" | "reserveProps" | "mangleQuoted" | "mangleCache" | "drop" | "dropLabels" | "minify" | "minifyWhitespace" | "minifyIdentifiers" | "minifySyntax" | "lineLimit" | "charset" | "treeShaking" | "ignoreAnnotations" | "jsx" | "jsxFactory" | "jsxFragment" | "jsxImportSource" | "jsxDev" | "jsxSideEffects" | "define" | "pure" | "keepNames" | "absPaths" | "color" | "logLevel" | "logLimit" | "logOverride" | "tsconfigRaw"> & z.z.core.$partial, z.ZodAny>>;
|
|
11
12
|
}, z.z.core.$strict>;
|
|
12
13
|
export declare const injectManifestOptions: z.ZodPipe<z.ZodObject<{
|
|
13
14
|
cwd: z.ZodPrefault<z.ZodString>;
|
|
14
15
|
useNativeEsbuild: z.ZodPrefault<z.ZodBoolean>;
|
|
16
|
+
rebuildOnChange: z.ZodPrefault<z.ZodBoolean>;
|
|
15
17
|
esbuildOptions: z.ZodPrefault<z.ZodRecord<z.ZodLiteral<"bundle" | "splitting" | "preserveSymlinks" | "external" | "packages" | "alias" | "loader" | "resolveExtensions" | "mainFields" | "conditions" | "allowOverwrite" | "tsconfig" | "outExtension" | "publicPath" | "inject" | "banner" | "footer" | "plugins" | "sourcemap" | "legalComments" | "sourceRoot" | "sourcesContent" | "format" | "globalName" | "target" | "supported" | "mangleProps" | "reserveProps" | "mangleQuoted" | "mangleCache" | "drop" | "dropLabels" | "minify" | "minifyWhitespace" | "minifyIdentifiers" | "minifySyntax" | "lineLimit" | "charset" | "treeShaking" | "ignoreAnnotations" | "jsx" | "jsxFactory" | "jsxFragment" | "jsxImportSource" | "jsxDev" | "jsxSideEffects" | "define" | "pure" | "keepNames" | "absPaths" | "color" | "logLevel" | "logLimit" | "logOverride" | "tsconfigRaw"> & z.z.core.$partial, z.ZodAny>>;
|
|
16
18
|
nextConfig: z.ZodOptional<z.ZodObject<{
|
|
17
19
|
assetPrefix: z.ZodOptional<z.ZodString>;
|
|
@@ -227,6 +229,7 @@ export declare const injectManifestOptions: z.ZodPipe<z.ZodObject<{
|
|
|
227
229
|
};
|
|
228
230
|
cwd: string;
|
|
229
231
|
useNativeEsbuild: boolean;
|
|
232
|
+
rebuildOnChange: boolean;
|
|
230
233
|
esbuildOptions: Partial<Record<"bundle" | "splitting" | "preserveSymlinks" | "external" | "packages" | "alias" | "loader" | "resolveExtensions" | "mainFields" | "conditions" | "allowOverwrite" | "tsconfig" | "outExtension" | "publicPath" | "inject" | "banner" | "footer" | "plugins" | "sourcemap" | "legalComments" | "sourceRoot" | "sourcesContent" | "format" | "globalName" | "target" | "supported" | "mangleProps" | "reserveProps" | "mangleQuoted" | "mangleCache" | "drop" | "dropLabels" | "minify" | "minifyWhitespace" | "minifyIdentifiers" | "minifySyntax" | "lineLimit" | "charset" | "treeShaking" | "ignoreAnnotations" | "jsx" | "jsxFactory" | "jsxFragment" | "jsxImportSource" | "jsxDev" | "jsxSideEffects" | "define" | "pure" | "keepNames" | "absPaths" | "color" | "logLevel" | "logLimit" | "logOverride" | "tsconfigRaw", any>>;
|
|
231
234
|
maximumFileSizeToCacheInBytes: number;
|
|
232
235
|
globFollow: boolean;
|
|
@@ -257,6 +260,7 @@ export declare const injectManifestOptions: z.ZodPipe<z.ZodObject<{
|
|
|
257
260
|
}, {
|
|
258
261
|
cwd: string;
|
|
259
262
|
useNativeEsbuild: boolean;
|
|
263
|
+
rebuildOnChange: boolean;
|
|
260
264
|
esbuildOptions: Partial<Record<"bundle" | "splitting" | "preserveSymlinks" | "external" | "packages" | "alias" | "loader" | "resolveExtensions" | "mainFields" | "conditions" | "allowOverwrite" | "tsconfig" | "outExtension" | "publicPath" | "inject" | "banner" | "footer" | "plugins" | "sourcemap" | "legalComments" | "sourceRoot" | "sourcesContent" | "format" | "globalName" | "target" | "supported" | "mangleProps" | "reserveProps" | "mangleQuoted" | "mangleCache" | "drop" | "dropLabels" | "minify" | "minifyWhitespace" | "minifyIdentifiers" | "minifySyntax" | "lineLimit" | "charset" | "treeShaking" | "ignoreAnnotations" | "jsx" | "jsxFactory" | "jsxFragment" | "jsxImportSource" | "jsxDev" | "jsxSideEffects" | "define" | "pure" | "keepNames" | "absPaths" | "color" | "logLevel" | "logLimit" | "logOverride" | "tsconfigRaw", any>>;
|
|
261
265
|
maximumFileSizeToCacheInBytes: number;
|
|
262
266
|
globFollow: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.schema.d.ts","sourceRoot":"","sources":["../src/index.schema.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,KAAK,CAAC;AAMpB,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"index.schema.d.ts","sourceRoot":"","sources":["../src/index.schema.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,KAAK,CAAC;AAMpB,eAAO,MAAM,YAAY;;;;;;;;;;oBAYvB,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBA8C6o0B,CAAC;sBAA+B,CAAC;oBAA6B,CAAC;;uBAAuD,CAAC;sBAA+B,CAAC;oBAA6B,CAAC;;;;;;;;;;mBAA+5E,CAAC;kBAAwB,CAAC;kBAAwB,CAAC;;;;;;;;;;;;oBAAo9D,CAAC;;;0BAAie,CAAC;6BAA4H,CAAC;;;;0BAAkiB,CAAC;;;;;;;;;qBAA4+C,CAAC;;;;;iCAA+sB,CAAC;0BAAoC,CAAC;;iBAAoC,CAAC;;iCAA0D,CAAC;wBAA8B,CAAC;8BAAkE,CAAC;;yBAA2C,CAAC;uBAAiC,CAAC;;4BAA+C,CAAC;mBAAmD,CAAC;qBAA4C,CAAC;+BAAyC,CAAC;;kBAA6L,CAAC;wBAAsO,CAAC;qCAA2R,CAAC;;;;;;;;;;;;;6BAAm0D,CAAC;iCAAwC,CAAC;;;;;;;qBAAowB,CAAC;0BAAgC,CAAC;sBAA4B,CAAC;;;;;;;;;;;0BAA21C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GANnwuC,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -50,13 +50,20 @@ export interface TurboPartial {
|
|
|
50
50
|
* to `false` if not on Windows, `true` otherwise.
|
|
51
51
|
*/
|
|
52
52
|
useNativeEsbuild?: boolean;
|
|
53
|
+
/**
|
|
54
|
+
* Whether to automatically rebuild when source file changes
|
|
55
|
+
* while in development mode.
|
|
56
|
+
*
|
|
57
|
+
* @default true
|
|
58
|
+
*/
|
|
59
|
+
rebuildOnChange?: boolean;
|
|
53
60
|
/**
|
|
54
61
|
* Options to configure the esbuild instance used to bundle
|
|
55
62
|
* the service worker.
|
|
56
63
|
*/
|
|
57
64
|
esbuildOptions?: EsbuildNativeOptions | EsbuildWasmOptions;
|
|
58
65
|
}
|
|
59
|
-
export interface TurboResolved extends Require<TurboPartial, "cwd" | "useNativeEsbuild" | "esbuildOptions"> {
|
|
66
|
+
export interface TurboResolved extends Require<TurboPartial, "cwd" | "useNativeEsbuild" | "rebuildOnChange" | "esbuildOptions"> {
|
|
60
67
|
}
|
|
61
68
|
export type InjectManifestOptions = Prettify<Omit<BasePartial & GlobPartial & InjectPartial & OptionalGlobDirectoryPartial & TurboPartial, "disablePrecacheManifest">>;
|
|
62
69
|
export type InjectManifestOptionsComplete = Prettify<Omit<Require<BaseResolved, "dontCacheBustURLsMatching"> & GlobResolved & InjectResolved & RequiredGlobDirectoryResolved & TurboResolved, "disablePrecacheManifest">> & {
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,cAAc,EACd,4BAA4B,EAC5B,6BAA6B,EAC9B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,IAAI,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,IAAI,kBAAkB,EAAE,MAAM,MAAM,CAAC;AAC7D,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,MAAM,uBAAuB,GAAG,CAAC,OAAO,yBAAyB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC,GAAG,SAAS,mBAAmB,GAAG,KAAK,GAAG,IAAI,CAAC,mBAAmB,EAAE,uBAAuB,CAAC,CAAC,CAAC;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AY,EAAE,yBAAyB,CAAC,CACzH,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG,QAAQ,CAClD,IAAI,CACF,OAAO,CAAC,YAAY,EAAE,2BAA2B,CAAC,GAAG,YAAY,GAAG,cAAc,GAAG,6BAA6B,GAAG,aAAa,EAClI,yBAAyB,CAC1B,CACF,GAAG;IACF,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;CAClC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@serwist/turbopack",
|
|
3
|
-
"version": "9.5.
|
|
3
|
+
"version": "9.5.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "A module that integrates Serwist into your Next.js / Turbopack application.",
|
|
@@ -66,29 +66,29 @@
|
|
|
66
66
|
"./package.json": "./package.json"
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@swc/core": "1.15.
|
|
69
|
+
"@swc/core": "1.15.18",
|
|
70
70
|
"browserslist": "4.28.1",
|
|
71
71
|
"kolorist": "1.8.0",
|
|
72
|
-
"semver": "7.7.
|
|
72
|
+
"semver": "7.7.4",
|
|
73
73
|
"zod": "4.3.6",
|
|
74
|
-
"@serwist/
|
|
75
|
-
"@serwist/
|
|
76
|
-
"serwist": "9.5.
|
|
77
|
-
"
|
|
74
|
+
"@serwist/utils": "9.5.7",
|
|
75
|
+
"@serwist/build": "9.5.7",
|
|
76
|
+
"@serwist/window": "9.5.7",
|
|
77
|
+
"serwist": "9.5.7"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
|
-
"@types/node": "25.
|
|
81
|
-
"@types/react": "19.2.
|
|
80
|
+
"@types/node": "25.5.0",
|
|
81
|
+
"@types/react": "19.2.14",
|
|
82
82
|
"@types/semver": "7.7.1",
|
|
83
|
-
"esbuild": "0.27.
|
|
84
|
-
"esbuild-wasm": "0.27.
|
|
83
|
+
"esbuild": "0.27.4",
|
|
84
|
+
"esbuild-wasm": "0.27.4",
|
|
85
85
|
"next": "16.1.6",
|
|
86
86
|
"react": "19.2.4",
|
|
87
87
|
"react-dom": "19.2.4",
|
|
88
|
-
"rollup": "4.
|
|
89
|
-
"type-fest": "5.4.
|
|
88
|
+
"rollup": "4.59.0",
|
|
89
|
+
"type-fest": "5.4.4",
|
|
90
90
|
"typescript": "5.9.3",
|
|
91
|
-
"@serwist/configs": "9.5.
|
|
91
|
+
"@serwist/configs": "9.5.7"
|
|
92
92
|
},
|
|
93
93
|
"peerDependencies": {
|
|
94
94
|
"esbuild": ">=0.25.0 <1.0.0",
|
package/src/index.schema.ts
CHANGED
|
@@ -17,6 +17,7 @@ export const turboPartial = z.strictObject({
|
|
|
17
17
|
})
|
|
18
18
|
.optional(),
|
|
19
19
|
useNativeEsbuild: z.boolean().prefault(process.platform === "win32"),
|
|
20
|
+
rebuildOnChange: z.boolean().prefault(true),
|
|
20
21
|
esbuildOptions: z.partialRecord(z.literal(SUPPORTED_ESBUILD_OPTIONS), z.any()).prefault({}),
|
|
21
22
|
});
|
|
22
23
|
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Workaround for Next.js + Turbopack, while plugins are still
|
|
2
2
|
// not supported. This relies on Next.js Route Handlers and file
|
|
3
3
|
// name determinism.
|
|
4
|
+
import crypto from "node:crypto";
|
|
5
|
+
import fs from "node:fs";
|
|
4
6
|
import path from "node:path";
|
|
5
7
|
import { type BuildResult, getFileManifestEntries, rebasePath } from "@serwist/build";
|
|
6
8
|
import { SerwistConfigError, validationErrorMap } from "@serwist/build/schema";
|
|
@@ -93,6 +95,7 @@ export const createSerwistRoute = (options: InjectManifestOptions) => {
|
|
|
93
95
|
],
|
|
94
96
|
};
|
|
95
97
|
});
|
|
98
|
+
let lastHash: string | null = null;
|
|
96
99
|
let map: Map<string, string> | null = null;
|
|
97
100
|
// NOTE: ALL FILES MUST HAVE DETERMINISTIC NAMES. THIS IS BECAUSE
|
|
98
101
|
// THE FOLLOWING MAP IS LOADED SEPARATELY FOR `generateStaticParams`
|
|
@@ -157,10 +160,16 @@ export const createSerwistRoute = (options: InjectManifestOptions) => {
|
|
|
157
160
|
return [...map.keys()].map((e) => ({ path: path.relative(config.cwd, e) }));
|
|
158
161
|
};
|
|
159
162
|
const GET = async (_: Request, { params }: { params: Promise<{ path: string }> }) => {
|
|
160
|
-
// TODO: obviously, files get stale in development when we pull this off.
|
|
161
163
|
const { path: filePath } = await params;
|
|
162
164
|
const config = await validation;
|
|
163
|
-
if (
|
|
165
|
+
if (isDev && config.rebuildOnChange) {
|
|
166
|
+
const swContent = fs.readFileSync(config.swSrc, "utf-8");
|
|
167
|
+
const currentHash = crypto.createHash("sha256").update(swContent).digest("hex");
|
|
168
|
+
if (!map || lastHash !== currentHash) {
|
|
169
|
+
map = await loadMap(filePath);
|
|
170
|
+
lastHash = currentHash;
|
|
171
|
+
}
|
|
172
|
+
} else if (!map) map = await loadMap(filePath);
|
|
164
173
|
return new NextResponse(map.get(path.join(config.cwd, filePath)), {
|
|
165
174
|
headers: {
|
|
166
175
|
"Content-Type": contentTypeMap[path.extname(filePath)] || "text/plain",
|
package/src/lib/utils.ts
CHANGED
|
@@ -6,9 +6,9 @@ export const loadNextConfig = async (cwd: string, isDev: boolean) => {
|
|
|
6
6
|
// for loading `next/dist/server/config.js`.
|
|
7
7
|
const nextConfig = await import(/* webpackIgnore: true */ "next/dist/server/config.js");
|
|
8
8
|
// 1) what does `default.default` even mean
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
});
|
|
9
|
+
const loadConfig =
|
|
10
|
+
typeof nextConfig.default === "function" ? (nextConfig.default as unknown as typeof nextConfig.default.default) : nextConfig.default.default;
|
|
11
|
+
return loadConfig(nextPhase, cwd, { silent: false });
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const generateGlobPatterns = (distDir: string) => [
|
package/src/types.ts
CHANGED
|
@@ -64,6 +64,13 @@ export interface TurboPartial {
|
|
|
64
64
|
* to `false` if not on Windows, `true` otherwise.
|
|
65
65
|
*/
|
|
66
66
|
useNativeEsbuild?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Whether to automatically rebuild when source file changes
|
|
69
|
+
* while in development mode.
|
|
70
|
+
*
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
rebuildOnChange?: boolean;
|
|
67
74
|
/**
|
|
68
75
|
* Options to configure the esbuild instance used to bundle
|
|
69
76
|
* the service worker.
|
|
@@ -71,7 +78,7 @@ export interface TurboPartial {
|
|
|
71
78
|
esbuildOptions?: EsbuildNativeOptions | EsbuildWasmOptions;
|
|
72
79
|
}
|
|
73
80
|
|
|
74
|
-
export interface TurboResolved extends Require<TurboPartial, "cwd" | "useNativeEsbuild" | "esbuildOptions"> {}
|
|
81
|
+
export interface TurboResolved extends Require<TurboPartial, "cwd" | "useNativeEsbuild" | "rebuildOnChange" | "esbuildOptions"> {}
|
|
75
82
|
|
|
76
83
|
export type InjectManifestOptions = Prettify<
|
|
77
84
|
Omit<BasePartial & GlobPartial & InjectPartial & OptionalGlobDirectoryPartial & TurboPartial, "disablePrecacheManifest">
|