@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/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { InputOptions, OutputOptions } from 'rolldown';
|
|
2
|
+
|
|
1
3
|
interface NastiConfig {
|
|
2
4
|
/** 项目根目录 */
|
|
3
5
|
root?: string;
|
|
@@ -87,10 +89,28 @@ interface BuildConfig {
|
|
|
87
89
|
minify?: boolean | 'oxc';
|
|
88
90
|
sourcemap?: boolean | 'inline' | 'hidden';
|
|
89
91
|
target?: string | string[];
|
|
90
|
-
|
|
92
|
+
/**
|
|
93
|
+
* 透传给 Rolldown 的底层选项,供生产应用手动控制代码拆分与 Tree-shaking。
|
|
94
|
+
*
|
|
95
|
+
* - input 侧(`treeshake`、`resolve`、`external`、`platform` 等)会合并进 `rolldown()`;
|
|
96
|
+
* - `output` 会合并进 `bundle.write()`,用于控制代码拆分
|
|
97
|
+
* (`output.advancedChunks` / `output.codeSplitting`)、chunk 命名等。
|
|
98
|
+
*
|
|
99
|
+
* 注:`input` 与 `plugins` 由 Nasti 管理,故不在此暴露;`output.dir` 始终由
|
|
100
|
+
* `build.outDir` 决定(HTML 改写依赖产物路径),传入会被忽略。
|
|
101
|
+
*/
|
|
102
|
+
rolldownOptions?: NastiRolldownOptions;
|
|
91
103
|
emptyOutDir?: boolean;
|
|
92
104
|
css?: CssConfig;
|
|
93
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Nasti 暴露的 Rolldown 选项:在 Rolldown {@link InputOptions} 基础上去掉由 Nasti
|
|
108
|
+
* 接管的 `input` / `plugins`,并补充一个 `output` 出口用于 `bundle.write()`。
|
|
109
|
+
*/
|
|
110
|
+
type NastiRolldownOptions = Omit<InputOptions, 'input' | 'plugins'> & {
|
|
111
|
+
/** 传给 `bundle.write()` 的输出选项:代码拆分(`advancedChunks` / `codeSplitting`)、chunk 命名等 */
|
|
112
|
+
output?: OutputOptions;
|
|
113
|
+
};
|
|
94
114
|
interface CssConfig {
|
|
95
115
|
/** CSP nonce to add to inline <style> tags */
|
|
96
116
|
nonce?: string;
|
|
@@ -330,4 +350,4 @@ interface MonacoEditorPluginOptions {
|
|
|
330
350
|
}
|
|
331
351
|
declare function monacoEditorPlugin(options?: MonacoEditorPluginOptions): NastiPlugin;
|
|
332
352
|
|
|
333
|
-
export { type DevServer, type ElectronConfig, type HmrPayload, type ModuleNode, type MonacoCustomWorker, type MonacoEditorLanguageWorker, type MonacoEditorPluginOptions, type NastiConfig, type NastiPlugin, type ResolvedConfig, type TransformResult, build, buildElectron, createServer, defineConfig, electronPlugin, monacoEditorPlugin, resolveConfig, startElectronDev };
|
|
353
|
+
export { type BuildConfig, type DevServer, type ElectronConfig, type HmrPayload, type ModuleNode, type MonacoCustomWorker, type MonacoEditorLanguageWorker, type MonacoEditorPluginOptions, type NastiConfig, type NastiPlugin, type NastiRolldownOptions, type ResolvedConfig, type TransformResult, build, buildElectron, createServer, defineConfig, electronPlugin, monacoEditorPlugin, resolveConfig, startElectronDev };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { InputOptions, OutputOptions } from 'rolldown';
|
|
2
|
+
|
|
1
3
|
interface NastiConfig {
|
|
2
4
|
/** 项目根目录 */
|
|
3
5
|
root?: string;
|
|
@@ -87,10 +89,28 @@ interface BuildConfig {
|
|
|
87
89
|
minify?: boolean | 'oxc';
|
|
88
90
|
sourcemap?: boolean | 'inline' | 'hidden';
|
|
89
91
|
target?: string | string[];
|
|
90
|
-
|
|
92
|
+
/**
|
|
93
|
+
* 透传给 Rolldown 的底层选项,供生产应用手动控制代码拆分与 Tree-shaking。
|
|
94
|
+
*
|
|
95
|
+
* - input 侧(`treeshake`、`resolve`、`external`、`platform` 等)会合并进 `rolldown()`;
|
|
96
|
+
* - `output` 会合并进 `bundle.write()`,用于控制代码拆分
|
|
97
|
+
* (`output.advancedChunks` / `output.codeSplitting`)、chunk 命名等。
|
|
98
|
+
*
|
|
99
|
+
* 注:`input` 与 `plugins` 由 Nasti 管理,故不在此暴露;`output.dir` 始终由
|
|
100
|
+
* `build.outDir` 决定(HTML 改写依赖产物路径),传入会被忽略。
|
|
101
|
+
*/
|
|
102
|
+
rolldownOptions?: NastiRolldownOptions;
|
|
91
103
|
emptyOutDir?: boolean;
|
|
92
104
|
css?: CssConfig;
|
|
93
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Nasti 暴露的 Rolldown 选项:在 Rolldown {@link InputOptions} 基础上去掉由 Nasti
|
|
108
|
+
* 接管的 `input` / `plugins`,并补充一个 `output` 出口用于 `bundle.write()`。
|
|
109
|
+
*/
|
|
110
|
+
type NastiRolldownOptions = Omit<InputOptions, 'input' | 'plugins'> & {
|
|
111
|
+
/** 传给 `bundle.write()` 的输出选项:代码拆分(`advancedChunks` / `codeSplitting`)、chunk 命名等 */
|
|
112
|
+
output?: OutputOptions;
|
|
113
|
+
};
|
|
94
114
|
interface CssConfig {
|
|
95
115
|
/** CSP nonce to add to inline <style> tags */
|
|
96
116
|
nonce?: string;
|
|
@@ -330,4 +350,4 @@ interface MonacoEditorPluginOptions {
|
|
|
330
350
|
}
|
|
331
351
|
declare function monacoEditorPlugin(options?: MonacoEditorPluginOptions): NastiPlugin;
|
|
332
352
|
|
|
333
|
-
export { type DevServer, type ElectronConfig, type HmrPayload, type ModuleNode, type MonacoCustomWorker, type MonacoEditorLanguageWorker, type MonacoEditorPluginOptions, type NastiConfig, type NastiPlugin, type ResolvedConfig, type TransformResult, build, buildElectron, createServer, defineConfig, electronPlugin, monacoEditorPlugin, resolveConfig, startElectronDev };
|
|
353
|
+
export { type BuildConfig, type DevServer, type ElectronConfig, type HmrPayload, type ModuleNode, type MonacoCustomWorker, type MonacoEditorLanguageWorker, type MonacoEditorPluginOptions, type NastiConfig, type NastiPlugin, type NastiRolldownOptions, type ResolvedConfig, type TransformResult, build, buildElectron, createServer, defineConfig, electronPlugin, monacoEditorPlugin, resolveConfig, startElectronDev };
|
package/dist/index.js
CHANGED
|
@@ -903,7 +903,7 @@ import pc from "picocolors";
|
|
|
903
903
|
async function build(inlineConfig = {}) {
|
|
904
904
|
const config = await resolveConfig(inlineConfig, "build");
|
|
905
905
|
const startTime = performance.now();
|
|
906
|
-
console.log(pc.cyan("\n\u{1F528} nasti build") + pc.dim(` v${"1.
|
|
906
|
+
console.log(pc.cyan("\n\u{1F528} nasti build") + pc.dim(` v${"1.7.0"}`));
|
|
907
907
|
console.log(pc.dim(` root: ${config.root}`));
|
|
908
908
|
console.log(pc.dim(` mode: ${config.mode}`));
|
|
909
909
|
const outDir = path8.resolve(config.root, config.build.outDir);
|
|
@@ -957,11 +957,12 @@ async function build(inlineConfig = {}) {
|
|
|
957
957
|
};
|
|
958
958
|
const env = loadEnv(config.mode, config.root, config.envPrefix);
|
|
959
959
|
const envDefine = buildEnvDefine(env, config.mode);
|
|
960
|
-
const
|
|
961
|
-
const mergedDefine = { ...
|
|
960
|
+
const { output: userOutput, transform: userTransform, ...restInputOptions } = config.build.rolldownOptions;
|
|
961
|
+
const mergedDefine = { ...userTransform?.define ?? {}, ...envDefine };
|
|
962
962
|
const bundle = await rolldown({
|
|
963
|
+
...restInputOptions,
|
|
963
964
|
input: entryPoints,
|
|
964
|
-
transform: { ...
|
|
965
|
+
transform: { ...userTransform, define: mergedDefine },
|
|
965
966
|
plugins: [
|
|
966
967
|
oxcTransformPlugin,
|
|
967
968
|
// 转换 Nasti 插件为 Rolldown 插件格式
|
|
@@ -977,17 +978,19 @@ async function build(inlineConfig = {}) {
|
|
|
977
978
|
// manifest/SW writers) rely on for final-stage artifact emission.
|
|
978
979
|
closeBundle: p.closeBundle
|
|
979
980
|
}))
|
|
980
|
-
]
|
|
981
|
-
...config.build.rolldownOptions
|
|
981
|
+
]
|
|
982
982
|
});
|
|
983
983
|
const { output } = await bundle.write({
|
|
984
|
-
dir: outDir,
|
|
985
984
|
format: "esm",
|
|
986
985
|
sourcemap: !!config.build.sourcemap,
|
|
987
986
|
minify: !!config.build.minify,
|
|
988
987
|
entryFileNames: "assets/[name].[hash].js",
|
|
989
988
|
chunkFileNames: "assets/[name].[hash].js",
|
|
990
|
-
assetFileNames: "assets/[name].[hash][extname]"
|
|
989
|
+
assetFileNames: "assets/[name].[hash][extname]",
|
|
990
|
+
// 用户可覆盖默认输出:代码拆分(advancedChunks / codeSplitting)、chunk 命名等
|
|
991
|
+
...userOutput,
|
|
992
|
+
// dir 始终由 Nasti 掌管 —— 下方 HTML 改写依赖固定的产物目录,故放在最后强制生效
|
|
993
|
+
dir: outDir
|
|
991
994
|
});
|
|
992
995
|
await bundle.close();
|
|
993
996
|
await pluginContainer.buildEnd();
|
|
@@ -2112,7 +2115,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
2112
2115
|
const localUrl = `http://localhost:${actualPort}`;
|
|
2113
2116
|
const networkUrl = host === "0.0.0.0" ? `http://${getNetworkAddress()}:${actualPort}` : null;
|
|
2114
2117
|
console.log();
|
|
2115
|
-
console.log(pc3.cyan(" nasti dev server") + pc3.dim(` v${"1.
|
|
2118
|
+
console.log(pc3.cyan(" nasti dev server") + pc3.dim(` v${"1.7.0"}`));
|
|
2116
2119
|
console.log();
|
|
2117
2120
|
console.log(` ${pc3.green(">")} Local: ${pc3.cyan(localUrl)}`);
|
|
2118
2121
|
if (networkUrl) {
|
|
@@ -2236,7 +2239,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
2236
2239
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
2237
2240
|
const startTime = performance.now();
|
|
2238
2241
|
assertElectronVersion(config);
|
|
2239
|
-
console.log(pc2.cyan("\n\u26A1 nasti build (electron)") + pc2.dim(` v${"1.
|
|
2242
|
+
console.log(pc2.cyan("\n\u26A1 nasti build (electron)") + pc2.dim(` v${"1.7.0"}`));
|
|
2240
2243
|
console.log(pc2.dim(` root: ${config.root}`));
|
|
2241
2244
|
console.log(pc2.dim(` mode: ${config.mode}`));
|
|
2242
2245
|
console.log(pc2.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -2314,21 +2317,23 @@ async function bundleNode(config, entry, opts) {
|
|
|
2314
2317
|
return { code: result.code, map: result.map ? JSON.parse(result.map) : void 0 };
|
|
2315
2318
|
}
|
|
2316
2319
|
};
|
|
2317
|
-
const
|
|
2318
|
-
const mergedDefine = { ...
|
|
2320
|
+
const { output: userOutput, transform: userTransform, ...restInputOptions } = config.build.rolldownOptions;
|
|
2321
|
+
const mergedDefine = { ...userTransform?.define ?? {}, ...envDefine };
|
|
2319
2322
|
const bundle = await rolldown2({
|
|
2323
|
+
...restInputOptions,
|
|
2320
2324
|
input: entry,
|
|
2321
|
-
transform: { ...existingTransform, define: mergedDefine },
|
|
2322
2325
|
platform: "node",
|
|
2323
|
-
|
|
2324
|
-
|
|
2326
|
+
transform: { ...userTransform, define: mergedDefine },
|
|
2327
|
+
plugins: [oxcTransformPlugin, electronPlugin(config), resolvePlugin(config)]
|
|
2325
2328
|
});
|
|
2326
2329
|
fs7.mkdirSync(path9.dirname(opts.outFile), { recursive: true });
|
|
2327
2330
|
await bundle.write({
|
|
2328
|
-
file: opts.outFile,
|
|
2329
|
-
format: opts.format === "cjs" ? "cjs" : "esm",
|
|
2330
2331
|
sourcemap: !!config.build.sourcemap,
|
|
2331
2332
|
minify: !!config.build.minify,
|
|
2333
|
+
// 允许用户微调 output;但主进程 / preload 的单文件约束由下方键强制保证
|
|
2334
|
+
...userOutput,
|
|
2335
|
+
file: opts.outFile,
|
|
2336
|
+
format: opts.format === "cjs" ? "cjs" : "esm",
|
|
2332
2337
|
codeSplitting: false
|
|
2333
2338
|
});
|
|
2334
2339
|
await bundle.close();
|
|
@@ -2385,7 +2390,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
2385
2390
|
const { noSpawn, ...rest } = inlineConfig;
|
|
2386
2391
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
2387
2392
|
warnElectronVersion(config);
|
|
2388
|
-
console.log(pc4.cyan("\n\u26A1 nasti electron dev") + pc4.dim(` v${"1.
|
|
2393
|
+
console.log(pc4.cyan("\n\u26A1 nasti electron dev") + pc4.dim(` v${"1.7.0"}`));
|
|
2389
2394
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
2390
2395
|
const server = await createServer2({ ...rest, target: "electron" });
|
|
2391
2396
|
await server.listen();
|