@nasti-toolchain/nasti 1.6.5 → 1.7.0
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/README.md +25 -0
- package/dist/cli.cjs +24 -19
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +24 -19
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +23 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -2
- package/dist/index.d.ts +22 -2
- package/dist/index.js +23 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -88,6 +88,31 @@ export default defineConfig({
|
|
|
88
88
|
})
|
|
89
89
|
```
|
|
90
90
|
|
|
91
|
+
### 生产构建:手动代码拆分 & Tree-shaking
|
|
92
|
+
|
|
93
|
+
`build.rolldownOptions` 透传 Rolldown 底层选项:input 侧(如 `treeshake`、`resolve`、`external`)合并进打包,`output` 合并进产物写出阶段,用于手动控制 vendor 分包与 Tree-shaking。`input` / `plugins` 由 Nasti 接管,`output.dir` 始终由 `build.outDir` 决定。
|
|
94
|
+
|
|
95
|
+
```ts
|
|
96
|
+
export default defineConfig({
|
|
97
|
+
build: {
|
|
98
|
+
rolldownOptions: {
|
|
99
|
+
// Tree-shaking(input 选项)
|
|
100
|
+
treeshake: { moduleSideEffects: [{ test: /\/barrel\//, sideEffects: false }] },
|
|
101
|
+
// 代码拆分(output 选项)
|
|
102
|
+
output: {
|
|
103
|
+
advancedChunks: {
|
|
104
|
+
groups: [
|
|
105
|
+
{ name: 'react-vendor', test: /node_modules[\\/]react/, priority: 20 },
|
|
106
|
+
{ name: 'vendor', test: /node_modules/, priority: 10 },
|
|
107
|
+
],
|
|
108
|
+
},
|
|
109
|
+
chunkFileNames: 'assets/chunks/[name].[hash].js',
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
})
|
|
114
|
+
```
|
|
115
|
+
|
|
91
116
|
## CLI
|
|
92
117
|
|
|
93
118
|
```bash
|
package/dist/cli.cjs
CHANGED
|
@@ -1966,7 +1966,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
1966
1966
|
const localUrl = `http://localhost:${actualPort}`;
|
|
1967
1967
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
1968
1968
|
console.log();
|
|
1969
|
-
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.
|
|
1969
|
+
console.log(import_picocolors.default.cyan(" nasti dev server") + import_picocolors.default.dim(` v${"1.7.0"}`));
|
|
1970
1970
|
console.log();
|
|
1971
1971
|
console.log(` ${import_picocolors.default.green(">")} Local: ${import_picocolors.default.cyan(localUrl)}`);
|
|
1972
1972
|
if (networkUrl) {
|
|
@@ -2093,7 +2093,7 @@ __export(build_exports, {
|
|
|
2093
2093
|
async function build(inlineConfig = {}) {
|
|
2094
2094
|
const config = await resolveConfig(inlineConfig, "build");
|
|
2095
2095
|
const startTime = performance.now();
|
|
2096
|
-
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.
|
|
2096
|
+
console.log(import_picocolors2.default.cyan("\n\u{1F528} nasti build") + import_picocolors2.default.dim(` v${"1.7.0"}`));
|
|
2097
2097
|
console.log(import_picocolors2.default.dim(` root: ${config.root}`));
|
|
2098
2098
|
console.log(import_picocolors2.default.dim(` mode: ${config.mode}`));
|
|
2099
2099
|
const outDir = import_node_path11.default.resolve(config.root, config.build.outDir);
|
|
@@ -2147,11 +2147,12 @@ async function build(inlineConfig = {}) {
|
|
|
2147
2147
|
};
|
|
2148
2148
|
const env = loadEnv(config.mode, config.root, config.envPrefix);
|
|
2149
2149
|
const envDefine = buildEnvDefine(env, config.mode);
|
|
2150
|
-
const
|
|
2151
|
-
const mergedDefine = { ...
|
|
2150
|
+
const { output: userOutput, transform: userTransform, ...restInputOptions } = config.build.rolldownOptions;
|
|
2151
|
+
const mergedDefine = { ...userTransform?.define ?? {}, ...envDefine };
|
|
2152
2152
|
const bundle = await (0, import_rolldown.rolldown)({
|
|
2153
|
+
...restInputOptions,
|
|
2153
2154
|
input: entryPoints,
|
|
2154
|
-
transform: { ...
|
|
2155
|
+
transform: { ...userTransform, define: mergedDefine },
|
|
2155
2156
|
plugins: [
|
|
2156
2157
|
oxcTransformPlugin,
|
|
2157
2158
|
// 转换 Nasti 插件为 Rolldown 插件格式
|
|
@@ -2167,17 +2168,19 @@ async function build(inlineConfig = {}) {
|
|
|
2167
2168
|
// manifest/SW writers) rely on for final-stage artifact emission.
|
|
2168
2169
|
closeBundle: p.closeBundle
|
|
2169
2170
|
}))
|
|
2170
|
-
]
|
|
2171
|
-
...config.build.rolldownOptions
|
|
2171
|
+
]
|
|
2172
2172
|
});
|
|
2173
2173
|
const { output } = await bundle.write({
|
|
2174
|
-
dir: outDir,
|
|
2175
2174
|
format: "esm",
|
|
2176
2175
|
sourcemap: !!config.build.sourcemap,
|
|
2177
2176
|
minify: !!config.build.minify,
|
|
2178
2177
|
entryFileNames: "assets/[name].[hash].js",
|
|
2179
2178
|
chunkFileNames: "assets/[name].[hash].js",
|
|
2180
|
-
assetFileNames: "assets/[name].[hash][extname]"
|
|
2179
|
+
assetFileNames: "assets/[name].[hash][extname]",
|
|
2180
|
+
// 用户可覆盖默认输出:代码拆分(advancedChunks / codeSplitting)、chunk 命名等
|
|
2181
|
+
...userOutput,
|
|
2182
|
+
// dir 始终由 Nasti 掌管 —— 下方 HTML 改写依赖固定的产物目录,故放在最后强制生效
|
|
2183
|
+
dir: outDir
|
|
2181
2184
|
});
|
|
2182
2185
|
await bundle.close();
|
|
2183
2186
|
await pluginContainer.buildEnd();
|
|
@@ -2260,7 +2263,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
2260
2263
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
2261
2264
|
const startTime = performance.now();
|
|
2262
2265
|
assertElectronVersion(config);
|
|
2263
|
-
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.
|
|
2266
|
+
console.log(import_picocolors3.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors3.default.dim(` v${"1.7.0"}`));
|
|
2264
2267
|
console.log(import_picocolors3.default.dim(` root: ${config.root}`));
|
|
2265
2268
|
console.log(import_picocolors3.default.dim(` mode: ${config.mode}`));
|
|
2266
2269
|
console.log(import_picocolors3.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -2338,21 +2341,23 @@ async function bundleNode(config, entry, opts) {
|
|
|
2338
2341
|
return { code: result.code, map: result.map ? JSON.parse(result.map) : void 0 };
|
|
2339
2342
|
}
|
|
2340
2343
|
};
|
|
2341
|
-
const
|
|
2342
|
-
const mergedDefine = { ...
|
|
2344
|
+
const { output: userOutput, transform: userTransform, ...restInputOptions } = config.build.rolldownOptions;
|
|
2345
|
+
const mergedDefine = { ...userTransform?.define ?? {}, ...envDefine };
|
|
2343
2346
|
const bundle = await (0, import_rolldown2.rolldown)({
|
|
2347
|
+
...restInputOptions,
|
|
2344
2348
|
input: entry,
|
|
2345
|
-
transform: { ...existingTransform, define: mergedDefine },
|
|
2346
2349
|
platform: "node",
|
|
2347
|
-
|
|
2348
|
-
|
|
2350
|
+
transform: { ...userTransform, define: mergedDefine },
|
|
2351
|
+
plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
|
|
2349
2352
|
});
|
|
2350
2353
|
import_node_fs9.default.mkdirSync(import_node_path12.default.dirname(opts.outFile), { recursive: true });
|
|
2351
2354
|
await bundle.write({
|
|
2352
|
-
file: opts.outFile,
|
|
2353
|
-
format: opts.format === "cjs" ? "cjs" : "esm",
|
|
2354
2355
|
sourcemap: !!config.build.sourcemap,
|
|
2355
2356
|
minify: !!config.build.minify,
|
|
2357
|
+
// 允许用户微调 output;但主进程 / preload 的单文件约束由下方键强制保证
|
|
2358
|
+
...userOutput,
|
|
2359
|
+
file: opts.outFile,
|
|
2360
|
+
format: opts.format === "cjs" ? "cjs" : "esm",
|
|
2356
2361
|
codeSplitting: false
|
|
2357
2362
|
});
|
|
2358
2363
|
await bundle.close();
|
|
@@ -2414,7 +2419,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
2414
2419
|
const { noSpawn, ...rest } = inlineConfig;
|
|
2415
2420
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
2416
2421
|
warnElectronVersion(config);
|
|
2417
|
-
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.
|
|
2422
|
+
console.log(import_picocolors4.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors4.default.dim(` v${"1.7.0"}`));
|
|
2418
2423
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
2419
2424
|
const server = await createServer2({ ...rest, target: "electron" });
|
|
2420
2425
|
await server.listen();
|
|
@@ -2749,6 +2754,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
2749
2754
|
}
|
|
2750
2755
|
});
|
|
2751
2756
|
cli.help();
|
|
2752
|
-
cli.version("1.
|
|
2757
|
+
cli.version("1.7.0");
|
|
2753
2758
|
cli.parse();
|
|
2754
2759
|
//# sourceMappingURL=cli.cjs.map
|