@nasti-toolchain/nasti 2.4.4 → 2.5.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 +76 -0
- package/dist/cli.cjs +219 -39
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +219 -39
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +580 -59
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -1
- package/dist/index.d.ts +85 -1
- package/dist/index.js +579 -59
- package/dist/index.js.map +1 -1
- package/package.json +14 -1
package/README.md
CHANGED
|
@@ -183,6 +183,82 @@ function myPlugin(): NastiPlugin {
|
|
|
183
183
|
}
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
+
## React pipeline
|
|
187
|
+
|
|
188
|
+
React projects keep the existing automatic JSX and Fast Refresh behavior. The transform is now
|
|
189
|
+
configured through a dedicated pipeline whose option names follow `@vitejs/plugin-react`:
|
|
190
|
+
|
|
191
|
+
```ts
|
|
192
|
+
export default defineConfig({
|
|
193
|
+
framework: 'react',
|
|
194
|
+
react: {
|
|
195
|
+
include: /\.[tj]sx?$/,
|
|
196
|
+
exclude: /node_modules/,
|
|
197
|
+
jsxRuntime: 'automatic',
|
|
198
|
+
jsxImportSource: 'react',
|
|
199
|
+
},
|
|
200
|
+
})
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
The pipeline stays in the legacy transform slot: existing plugins still receive the same source
|
|
204
|
+
shape and run in the same order in development and production.
|
|
205
|
+
|
|
206
|
+
### React Compiler (experimental)
|
|
207
|
+
|
|
208
|
+
Install the optional native compiler and enable it explicitly:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
npm install -D oxc-transform-react
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
export default defineConfig({
|
|
216
|
+
framework: 'react',
|
|
217
|
+
react: {
|
|
218
|
+
compiler: true,
|
|
219
|
+
// Or: compiler: { compilationMode: 'annotation', target: '19' },
|
|
220
|
+
},
|
|
221
|
+
})
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
Compiler optimization is limited to `client` consumers. Server environments still use the same
|
|
225
|
+
JSX runtime transform without compiling component memoization, which keeps server/client graphs
|
|
226
|
+
explicit for full-stack frameworks.
|
|
227
|
+
|
|
228
|
+
### RSC reference generator (experimental)
|
|
229
|
+
|
|
230
|
+
The opt-in `rsc()` plugin provides the low-level bundler generation needed by React Server
|
|
231
|
+
Components: `"use client"` proxies in the RSC graph, file-level `"use server"` references,
|
|
232
|
+
automatic client-boundary entries, the `react-server` condition, and an inspectable chunk
|
|
233
|
+
manifest.
|
|
234
|
+
|
|
235
|
+
```bash
|
|
236
|
+
npm install react-server-dom-webpack
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
import { defineConfig, rsc } from '@nasti-toolchain/nasti'
|
|
241
|
+
|
|
242
|
+
export default defineConfig({
|
|
243
|
+
framework: 'react',
|
|
244
|
+
plugins: [
|
|
245
|
+
rsc({
|
|
246
|
+
entries: {
|
|
247
|
+
client: 'src/entry.client.tsx',
|
|
248
|
+
ssr: 'src/entry.ssr.tsx',
|
|
249
|
+
rsc: 'src/entry.rsc.tsx',
|
|
250
|
+
},
|
|
251
|
+
}),
|
|
252
|
+
],
|
|
253
|
+
})
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
Production builds emit `rsc-manifest.json`, mapping stable `/<root-relative-module>#<export>`
|
|
257
|
+
reference IDs to real client/RSC chunks. A framework remains responsible for request routing,
|
|
258
|
+
Flight streaming, and installing its server-function dispatcher at
|
|
259
|
+
`globalThis[Symbol.for('nasti.rsc.callServer')]`. This split lets Kunlun Next.js own application
|
|
260
|
+
conventions without coupling Nasti to a specific runtime.
|
|
261
|
+
|
|
186
262
|
## Vue 支持
|
|
187
263
|
|
|
188
264
|
Vue 支持需要安装可选依赖:
|
package/dist/cli.cjs
CHANGED
|
@@ -157,7 +157,7 @@ var init_logger = __esm({
|
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
// src/config/defaults.ts
|
|
160
|
-
var defaultResolve, defaultServer, defaultBuild, defaultElectron, defaultExperimental, defaults;
|
|
160
|
+
var defaultResolve, defaultServer, defaultBuild, defaultElectron, defaultExperimental, defaultReact, defaults;
|
|
161
161
|
var init_defaults = __esm({
|
|
162
162
|
"src/config/defaults.ts"() {
|
|
163
163
|
"use strict";
|
|
@@ -210,12 +210,20 @@ var init_defaults = __esm({
|
|
|
210
210
|
defaultExperimental = {
|
|
211
211
|
bundledDev: false
|
|
212
212
|
};
|
|
213
|
+
defaultReact = {
|
|
214
|
+
include: /\.[tj]sx?$/,
|
|
215
|
+
exclude: /node_modules/,
|
|
216
|
+
jsxImportSource: "react",
|
|
217
|
+
jsxRuntime: "automatic",
|
|
218
|
+
compiler: false
|
|
219
|
+
};
|
|
213
220
|
defaults = {
|
|
214
221
|
root: ".",
|
|
215
222
|
base: "/",
|
|
216
223
|
mode: "development",
|
|
217
224
|
target: "web",
|
|
218
225
|
framework: "auto",
|
|
226
|
+
react: defaultReact,
|
|
219
227
|
resolve: defaultResolve,
|
|
220
228
|
server: defaultServer,
|
|
221
229
|
build: defaultBuild,
|
|
@@ -437,6 +445,13 @@ async function resolveConfig(inlineConfig = {}, command) {
|
|
|
437
445
|
mode,
|
|
438
446
|
target: merged.target ?? defaults.target,
|
|
439
447
|
framework: (merged.framework ?? defaults.framework) === "auto" ? detectFramework(root) : merged.framework,
|
|
448
|
+
react: {
|
|
449
|
+
include: merged.react?.include ?? defaultReact.include,
|
|
450
|
+
exclude: merged.react?.exclude ?? defaultReact.exclude,
|
|
451
|
+
jsxImportSource: merged.react?.jsxImportSource ?? defaultReact.jsxImportSource,
|
|
452
|
+
jsxRuntime: merged.react?.jsxRuntime ?? defaultReact.jsxRuntime,
|
|
453
|
+
compiler: merged.react?.compiler === true ? {} : merged.react?.compiler ?? defaultReact.compiler
|
|
454
|
+
},
|
|
440
455
|
command,
|
|
441
456
|
resolve: {
|
|
442
457
|
// tsconfig paths 优先级最低:tsconfig < defaults < user config
|
|
@@ -1354,7 +1369,81 @@ ${msg}`);
|
|
|
1354
1369
|
map: result.map ? JSON.stringify(result.map) : null
|
|
1355
1370
|
};
|
|
1356
1371
|
}
|
|
1357
|
-
|
|
1372
|
+
async function transformReactCode(filename, code, options) {
|
|
1373
|
+
if (!matchesReactFilter(filename, options.react.include, options.react.exclude)) {
|
|
1374
|
+
return null;
|
|
1375
|
+
}
|
|
1376
|
+
if (!options.react.compiler) {
|
|
1377
|
+
if (!shouldTransform(filename)) return null;
|
|
1378
|
+
return transformCode(filename, code, {
|
|
1379
|
+
sourcemap: options.sourcemap,
|
|
1380
|
+
jsxRuntime: options.react.jsxRuntime,
|
|
1381
|
+
jsxImportSource: options.react.jsxImportSource,
|
|
1382
|
+
reactRefresh: options.reactRefresh,
|
|
1383
|
+
target: options.target
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
if (!shouldTransform(filename)) return null;
|
|
1387
|
+
const compiler2 = await loadReactCompiler();
|
|
1388
|
+
const compilerOptions = options.react.compiler;
|
|
1389
|
+
const shouldCompile = options.consumer === "client" && (compilerOptions.compilationMode === "annotation" ? /['"]use memo['"]/.test(code) : defaultReactCompilerCodeFilter.test(code));
|
|
1390
|
+
const result = await compiler2.transform(cleanTransformId(filename), code, {
|
|
1391
|
+
jsx: {
|
|
1392
|
+
runtime: options.react.jsxRuntime,
|
|
1393
|
+
development: options.development,
|
|
1394
|
+
importSource: options.react.jsxImportSource,
|
|
1395
|
+
refresh: options.consumer === "client" && !!options.reactRefresh
|
|
1396
|
+
},
|
|
1397
|
+
reactCompiler: shouldCompile ? compilerOptions : false,
|
|
1398
|
+
sourcemap: options.sourcemap ?? true
|
|
1399
|
+
});
|
|
1400
|
+
const diagnostics = result.errors.map(
|
|
1401
|
+
(error) => `${error.message}${error.codeframe ? `
|
|
1402
|
+
${error.codeframe}` : ""}`
|
|
1403
|
+
);
|
|
1404
|
+
if (result.fatal) {
|
|
1405
|
+
throw new Error(
|
|
1406
|
+
diagnostics.join("\n\n") || `React Compiler transform failed for ${filename}`
|
|
1407
|
+
);
|
|
1408
|
+
}
|
|
1409
|
+
for (const diagnostic of diagnostics) options.onWarning?.(diagnostic);
|
|
1410
|
+
return {
|
|
1411
|
+
code: result.code,
|
|
1412
|
+
map: result.map ? JSON.stringify(result.map) : null
|
|
1413
|
+
};
|
|
1414
|
+
}
|
|
1415
|
+
function matchesReactFilter(id, include, exclude) {
|
|
1416
|
+
const cleanId = cleanTransformId(id);
|
|
1417
|
+
return matchesFilter(cleanId, include) && !matchesFilter(cleanId, exclude);
|
|
1418
|
+
}
|
|
1419
|
+
function matchesFilter(id, filter2) {
|
|
1420
|
+
const patterns = Array.isArray(filter2) ? filter2 : [filter2];
|
|
1421
|
+
return patterns.some((pattern) => {
|
|
1422
|
+
if (pattern instanceof RegExp) {
|
|
1423
|
+
pattern.lastIndex = 0;
|
|
1424
|
+
return pattern.test(id);
|
|
1425
|
+
}
|
|
1426
|
+
if (!pattern.includes("*")) return id.includes(pattern);
|
|
1427
|
+
const expression = pattern.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, "\0").replace(/\*/g, "[^/]*").replace(/\0/g, ".*");
|
|
1428
|
+
return new RegExp(`^${expression}$`).test(id);
|
|
1429
|
+
});
|
|
1430
|
+
}
|
|
1431
|
+
function cleanTransformId(id) {
|
|
1432
|
+
return id.split(/[?#]/, 1)[0];
|
|
1433
|
+
}
|
|
1434
|
+
async function loadReactCompiler() {
|
|
1435
|
+
if (reactCompilerImplementation) return reactCompilerImplementation;
|
|
1436
|
+
try {
|
|
1437
|
+
reactCompilerImplementation = await import("oxc-transform-react");
|
|
1438
|
+
return reactCompilerImplementation;
|
|
1439
|
+
} catch (error) {
|
|
1440
|
+
throw new Error(
|
|
1441
|
+
'[nasti] React Compiler requires the optional "oxc-transform-react" package. Install it before setting react.compiler.' + (error instanceof Error ? `
|
|
1442
|
+
${error.message}` : "")
|
|
1443
|
+
);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
var import_oxc_transform, JS_EXTENSIONS, TS_EXTENSIONS, JSX_EXTENSIONS, defaultReactCompilerCodeFilter, reactCompilerImplementation;
|
|
1358
1447
|
var init_transformer = __esm({
|
|
1359
1448
|
"src/core/transformer.ts"() {
|
|
1360
1449
|
"use strict";
|
|
@@ -1362,6 +1451,7 @@ var init_transformer = __esm({
|
|
|
1362
1451
|
JS_EXTENSIONS = /\.(js|mjs|cjs)$/;
|
|
1363
1452
|
TS_EXTENSIONS = /\.(ts|mts|cts)$/;
|
|
1364
1453
|
JSX_EXTENSIONS = /\.(jsx|tsx)$/;
|
|
1454
|
+
defaultReactCompilerCodeFilter = /forwardRef|memo|\b(?:[A-Z]|use[A-Z0-9])/;
|
|
1365
1455
|
}
|
|
1366
1456
|
});
|
|
1367
1457
|
|
|
@@ -1993,22 +2083,35 @@ async function transformRequest(url, ctx) {
|
|
|
1993
2083
|
}
|
|
1994
2084
|
const stableUrl = cleanReqUrl;
|
|
1995
2085
|
let wrappedWithRefresh = false;
|
|
1996
|
-
if (
|
|
1997
|
-
const
|
|
1998
|
-
const useRefresh =
|
|
2086
|
+
if (config.framework === "react") {
|
|
2087
|
+
const refreshEnabled = (ctx.environment?.consumer ?? "client") === "client" && config.server.hmr !== false;
|
|
2088
|
+
const useRefresh = refreshEnabled && (!!config.react.compiler || /\.[jt]sx$/.test(filePath));
|
|
2089
|
+
const result = await transformReactCode(filePath, code, {
|
|
2090
|
+
react: config.react,
|
|
2091
|
+
consumer: ctx.environment?.consumer ?? "client",
|
|
2092
|
+
development: true,
|
|
2093
|
+
reactRefresh: useRefresh,
|
|
2094
|
+
sourcemap: true,
|
|
2095
|
+
target: ctx.environment?.options.build.target ?? config.build.target,
|
|
2096
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
2097
|
+
});
|
|
2098
|
+
if (result) {
|
|
2099
|
+
code = result.code;
|
|
2100
|
+
if (result.map) map = JSON.parse(result.map);
|
|
2101
|
+
if (useRefresh) {
|
|
2102
|
+
code = buildReactRefreshWrapper(stableUrl, code);
|
|
2103
|
+
wrappedWithRefresh = true;
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2106
|
+
} else if (shouldTransform(filePath)) {
|
|
1999
2107
|
const result = transformCode(filePath, code, {
|
|
2000
2108
|
sourcemap: true,
|
|
2001
2109
|
jsxRuntime: "automatic",
|
|
2002
|
-
jsxImportSource:
|
|
2003
|
-
reactRefresh: useRefresh,
|
|
2110
|
+
jsxImportSource: "vue",
|
|
2004
2111
|
target: ctx.environment?.options.build.target ?? config.build.target
|
|
2005
2112
|
});
|
|
2006
2113
|
code = result.code;
|
|
2007
2114
|
if (result.map) map = JSON.parse(result.map);
|
|
2008
|
-
if (useRefresh) {
|
|
2009
|
-
code = buildReactRefreshWrapper(stableUrl, code);
|
|
2010
|
-
wrappedWithRefresh = true;
|
|
2011
|
-
}
|
|
2012
2115
|
}
|
|
2013
2116
|
const hotInfo = rewriteHotAcceptDeps(code, config, filePath);
|
|
2014
2117
|
code = hotInfo.code;
|
|
@@ -4964,12 +5067,32 @@ var init_runnable_environment = __esm({
|
|
|
4964
5067
|
if (transformed != null) {
|
|
4965
5068
|
code = typeof transformed === "string" ? transformed : transformed.code;
|
|
4966
5069
|
}
|
|
4967
|
-
if (
|
|
5070
|
+
if (this.config.framework === "react") {
|
|
5071
|
+
const result = await transformReactCode(cleanId, code, {
|
|
5072
|
+
react: this.config.react,
|
|
5073
|
+
consumer: this.environment.consumer,
|
|
5074
|
+
development: true,
|
|
5075
|
+
sourcemap: false,
|
|
5076
|
+
target: this.environment.options.build.target,
|
|
5077
|
+
onWarning: (message) => this.config.logger.warn(`[nasti:react] ${message}`)
|
|
5078
|
+
});
|
|
5079
|
+
if (result) {
|
|
5080
|
+
code = result.code;
|
|
5081
|
+
} else if (shouldTransform(cleanId)) {
|
|
5082
|
+
const fallback = transformCode(cleanId, code, {
|
|
5083
|
+
sourcemap: false,
|
|
5084
|
+
jsxRuntime: this.config.react.jsxRuntime,
|
|
5085
|
+
jsxImportSource: this.config.react.jsxImportSource,
|
|
5086
|
+
target: this.environment.options.build.target
|
|
5087
|
+
});
|
|
5088
|
+
code = fallback.code;
|
|
5089
|
+
}
|
|
5090
|
+
} else if (shouldTransform(cleanId)) {
|
|
4968
5091
|
const result = transformCode(cleanId, code, {
|
|
4969
5092
|
sourcemap: false,
|
|
4970
5093
|
target: this.environment.options.build.target,
|
|
4971
5094
|
jsxRuntime: "automatic",
|
|
4972
|
-
jsxImportSource:
|
|
5095
|
+
jsxImportSource: "vue"
|
|
4973
5096
|
});
|
|
4974
5097
|
code = result.code;
|
|
4975
5098
|
}
|
|
@@ -5085,6 +5208,44 @@ var init_runnable_environment = __esm({
|
|
|
5085
5208
|
}
|
|
5086
5209
|
});
|
|
5087
5210
|
|
|
5211
|
+
// src/plugins/react.ts
|
|
5212
|
+
function reactPlugin(config, environment) {
|
|
5213
|
+
return {
|
|
5214
|
+
name: "nasti:oxc-transform",
|
|
5215
|
+
async transform(code, id) {
|
|
5216
|
+
const result = await transformReactCode(id, code, {
|
|
5217
|
+
react: config.react,
|
|
5218
|
+
consumer: environment.consumer,
|
|
5219
|
+
development: config.mode === "development",
|
|
5220
|
+
sourcemap: !!environment.options.build.sourcemap,
|
|
5221
|
+
target: environment.options.build.target,
|
|
5222
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
5223
|
+
});
|
|
5224
|
+
if (!result) return null;
|
|
5225
|
+
return {
|
|
5226
|
+
code: result.code,
|
|
5227
|
+
map: result.map ? JSON.parse(result.map) : void 0
|
|
5228
|
+
};
|
|
5229
|
+
},
|
|
5230
|
+
handleHotUpdate(ctx) {
|
|
5231
|
+
for (const mod of ctx.modules) {
|
|
5232
|
+
if (REACT_FILE_RE.test(mod.url) && matchesReactFilter(mod.url, config.react.include, config.react.exclude)) {
|
|
5233
|
+
mod.isSelfAccepting = true;
|
|
5234
|
+
}
|
|
5235
|
+
}
|
|
5236
|
+
return ctx.modules;
|
|
5237
|
+
}
|
|
5238
|
+
};
|
|
5239
|
+
}
|
|
5240
|
+
var REACT_FILE_RE;
|
|
5241
|
+
var init_react = __esm({
|
|
5242
|
+
"src/plugins/react.ts"() {
|
|
5243
|
+
"use strict";
|
|
5244
|
+
init_transformer();
|
|
5245
|
+
REACT_FILE_RE = /\.[jt]sx(?:[?#].*)?$/;
|
|
5246
|
+
}
|
|
5247
|
+
});
|
|
5248
|
+
|
|
5088
5249
|
// src/build/reporter.ts
|
|
5089
5250
|
async function tryNativeReporterPlugin(config, logger) {
|
|
5090
5251
|
try {
|
|
@@ -5377,7 +5538,7 @@ function getRolldownOptions(environment, entryPoints, rolldownPlugins) {
|
|
|
5377
5538
|
// 相对/绝对/虚拟模块照常打包。需要内联依赖时经 rolldownOptions.external 覆盖。
|
|
5378
5539
|
external: restInputOptions.external ?? ((id) => {
|
|
5379
5540
|
if (NODE_BUILTINS2.has(id)) return true;
|
|
5380
|
-
return !id.startsWith(".") && !import_node_path14.default.isAbsolute(id) && !id.startsWith("\0");
|
|
5541
|
+
return !id.startsWith(".") && !import_node_path14.default.isAbsolute(id) && !id.startsWith("\0") && !id.startsWith("virtual:");
|
|
5381
5542
|
})
|
|
5382
5543
|
} : {}
|
|
5383
5544
|
};
|
|
@@ -5600,6 +5761,7 @@ function resolveClientEntries(config, html) {
|
|
|
5600
5761
|
return entryPoints;
|
|
5601
5762
|
}
|
|
5602
5763
|
function createOxcTransformPlugin(config, environment) {
|
|
5764
|
+
if (config.framework === "react") return reactPlugin(config, environment);
|
|
5603
5765
|
return {
|
|
5604
5766
|
name: "nasti:oxc-transform",
|
|
5605
5767
|
transform(code, id) {
|
|
@@ -5620,7 +5782,7 @@ async function build(inlineConfig = {}) {
|
|
|
5620
5782
|
const startTime = performance.now();
|
|
5621
5783
|
logger.info(
|
|
5622
5784
|
import_picocolors6.default.cyan(`
|
|
5623
|
-
nasti v${"2.
|
|
5785
|
+
nasti v${"2.5.0"} `) + import_picocolors6.default.green(`building for ${config.mode}...`)
|
|
5624
5786
|
);
|
|
5625
5787
|
debug6?.(`root: ${config.root}`);
|
|
5626
5788
|
const buildableNames = Object.keys(config.environments).filter((name) => {
|
|
@@ -5906,6 +6068,7 @@ var init_build = __esm({
|
|
|
5906
6068
|
init_environment();
|
|
5907
6069
|
init_css_engine();
|
|
5908
6070
|
init_html();
|
|
6071
|
+
init_react();
|
|
5909
6072
|
init_transformer();
|
|
5910
6073
|
init_env();
|
|
5911
6074
|
init_reporter();
|
|
@@ -5949,11 +6112,11 @@ async function createBundledDevServer(opts) {
|
|
|
5949
6112
|
const patches = new MemoryFiles();
|
|
5950
6113
|
const entryFileNames = /* @__PURE__ */ new Map();
|
|
5951
6114
|
const bundledClients = /* @__PURE__ */ new Map();
|
|
5952
|
-
const useReactRefresh = config.framework
|
|
6115
|
+
const useReactRefresh = config.framework === "react" && config.server.hmr !== false && refreshWrapperFn != null;
|
|
5953
6116
|
const rolldownPlugins = [
|
|
5954
6117
|
...useReactRefresh ? [
|
|
5955
6118
|
createReactRefreshRuntimePlugin(entryPoints),
|
|
5956
|
-
createBundledOxcRefreshPlugin()
|
|
6119
|
+
createBundledOxcRefreshPlugin(config)
|
|
5957
6120
|
] : [],
|
|
5958
6121
|
...stripCatchAllLoad(toRolldownPlugins(clientEnv.plugins, clientEnv)),
|
|
5959
6122
|
...useReactRefresh ? [
|
|
@@ -6224,18 +6387,21 @@ ${code}`, map: null };
|
|
|
6224
6387
|
}
|
|
6225
6388
|
};
|
|
6226
6389
|
}
|
|
6227
|
-
function createBundledOxcRefreshPlugin() {
|
|
6390
|
+
function createBundledOxcRefreshPlugin(config) {
|
|
6228
6391
|
return {
|
|
6229
6392
|
name: "nasti:bundled-oxc-refresh",
|
|
6230
|
-
transform(code, id) {
|
|
6393
|
+
async transform(code, id) {
|
|
6231
6394
|
const clean = id.split("?")[0];
|
|
6232
|
-
|
|
6233
|
-
|
|
6395
|
+
const result = await transformReactCode(clean, code, {
|
|
6396
|
+
react: config.react,
|
|
6397
|
+
consumer: "client",
|
|
6398
|
+
development: true,
|
|
6399
|
+
reactRefresh: true,
|
|
6234
6400
|
sourcemap: true,
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
reactRefresh: true
|
|
6401
|
+
target: config.build.target,
|
|
6402
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
6238
6403
|
});
|
|
6404
|
+
if (!result) return null;
|
|
6239
6405
|
return { code: result.code, map: result.map ? JSON.parse(result.map) : void 0 };
|
|
6240
6406
|
}
|
|
6241
6407
|
};
|
|
@@ -6671,7 +6837,7 @@ async function createServer(inlineConfig = {}) {
|
|
|
6671
6837
|
const readyIn = Math.ceil(performance.now() - startTime);
|
|
6672
6838
|
logger.info(
|
|
6673
6839
|
`
|
|
6674
|
-
${import_picocolors8.default.cyan(import_picocolors8.default.bold("NASTI"))} ${import_picocolors8.default.cyan(`v${"2.
|
|
6840
|
+
${import_picocolors8.default.cyan(import_picocolors8.default.bold("NASTI"))} ${import_picocolors8.default.cyan(`v${"2.5.0"}`)} ${import_picocolors8.default.dim("ready in")} ${import_picocolors8.default.bold(readyIn)} ${import_picocolors8.default.dim("ms")}
|
|
6675
6841
|
`
|
|
6676
6842
|
);
|
|
6677
6843
|
printServerUrls(
|
|
@@ -6870,7 +7036,7 @@ async function buildElectron(inlineConfig = {}) {
|
|
|
6870
7036
|
const config = await resolveConfig({ ...inlineConfig, target: "electron" }, "build");
|
|
6871
7037
|
const startTime = performance.now();
|
|
6872
7038
|
assertElectronVersion(config);
|
|
6873
|
-
console.log(import_picocolors9.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors9.default.dim(` v${"2.
|
|
7039
|
+
console.log(import_picocolors9.default.cyan("\n\u26A1 nasti build (electron)") + import_picocolors9.default.dim(` v${"2.5.0"}`));
|
|
6874
7040
|
console.log(import_picocolors9.default.dim(` root: ${config.root}`));
|
|
6875
7041
|
console.log(import_picocolors9.default.dim(` mode: ${config.mode}`));
|
|
6876
7042
|
console.log(import_picocolors9.default.dim(` target: electron (\u2265 ${config.electron.minVersion})`));
|
|
@@ -6936,14 +7102,21 @@ async function bundleNode(config, entry, opts) {
|
|
|
6936
7102
|
};
|
|
6937
7103
|
const oxcTransformPlugin = {
|
|
6938
7104
|
name: "nasti:oxc-transform",
|
|
6939
|
-
transform(code, id) {
|
|
6940
|
-
|
|
6941
|
-
|
|
7105
|
+
async transform(code, id) {
|
|
7106
|
+
const result = config.framework === "react" ? await transformReactCode(id, code, {
|
|
7107
|
+
react: config.react,
|
|
7108
|
+
consumer: "server",
|
|
7109
|
+
development: config.mode === "development",
|
|
7110
|
+
sourcemap: !!config.build.sourcemap,
|
|
7111
|
+
target: config.electron.nodeTarget,
|
|
7112
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
7113
|
+
}) : shouldTransform(id) ? transformCode(id, code, {
|
|
6942
7114
|
sourcemap: !!config.build.sourcemap,
|
|
6943
7115
|
jsxRuntime: "automatic",
|
|
6944
|
-
jsxImportSource:
|
|
7116
|
+
jsxImportSource: "vue",
|
|
6945
7117
|
target: config.electron.nodeTarget
|
|
6946
|
-
});
|
|
7118
|
+
}) : null;
|
|
7119
|
+
if (!result) return null;
|
|
6947
7120
|
return { code: result.code, map: result.map ? JSON.parse(result.map) : void 0 };
|
|
6948
7121
|
}
|
|
6949
7122
|
};
|
|
@@ -7058,7 +7231,7 @@ async function startElectronDev(inlineConfig = {}) {
|
|
|
7058
7231
|
const { noSpawn, ...rest } = inlineConfig;
|
|
7059
7232
|
const config = await resolveConfig({ ...rest, target: "electron" }, "serve");
|
|
7060
7233
|
warnElectronVersion(config);
|
|
7061
|
-
console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.
|
|
7234
|
+
console.log(import_picocolors10.default.cyan("\n\u26A1 nasti electron dev") + import_picocolors10.default.dim(` v${"2.5.0"}`));
|
|
7062
7235
|
const { createServer: createServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
7063
7236
|
const server = await createServer2({
|
|
7064
7237
|
...rest,
|
|
@@ -7183,14 +7356,21 @@ async function compileNode(config, entry, opts) {
|
|
|
7183
7356
|
};
|
|
7184
7357
|
const oxcTransformPlugin = {
|
|
7185
7358
|
name: "nasti:oxc-transform",
|
|
7186
|
-
transform(code, id) {
|
|
7187
|
-
|
|
7188
|
-
|
|
7359
|
+
async transform(code, id) {
|
|
7360
|
+
const result = config.framework === "react" ? await transformReactCode(id, code, {
|
|
7361
|
+
react: config.react,
|
|
7362
|
+
consumer: "server",
|
|
7363
|
+
development: true,
|
|
7364
|
+
sourcemap: true,
|
|
7365
|
+
target: config.electron.nodeTarget,
|
|
7366
|
+
onWarning: (message) => config.logger.warn(`[nasti:react] ${message}`)
|
|
7367
|
+
}) : shouldTransform(id) ? transformCode(id, code, {
|
|
7189
7368
|
sourcemap: true,
|
|
7190
7369
|
jsxRuntime: "automatic",
|
|
7191
|
-
jsxImportSource:
|
|
7370
|
+
jsxImportSource: "vue",
|
|
7192
7371
|
target: config.electron.nodeTarget
|
|
7193
|
-
});
|
|
7372
|
+
}) : null;
|
|
7373
|
+
if (!result) return null;
|
|
7194
7374
|
return { code: result.code, map: result.map ? JSON.parse(result.map) : void 0 };
|
|
7195
7375
|
}
|
|
7196
7376
|
};
|
|
@@ -7423,7 +7603,7 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
7423
7603
|
const host = options.host === true ? "0.0.0.0" : options.host ?? "localhost";
|
|
7424
7604
|
http2.createServer(app).listen(port, host, () => {
|
|
7425
7605
|
logger.info(`
|
|
7426
|
-
${import_picocolors11.default.cyan(import_picocolors11.default.bold("NASTI"))} ${import_picocolors11.default.cyan(`v${"2.
|
|
7606
|
+
${import_picocolors11.default.cyan(import_picocolors11.default.bold("NASTI"))} ${import_picocolors11.default.cyan(`v${"2.5.0"}`)} ${import_picocolors11.default.dim("preview")}
|
|
7427
7607
|
`);
|
|
7428
7608
|
printServerUrls2(
|
|
7429
7609
|
{
|
|
@@ -7440,6 +7620,6 @@ cli.command("preview [root]", "Preview production build").option("--port <port>"
|
|
|
7440
7620
|
}
|
|
7441
7621
|
});
|
|
7442
7622
|
cli.help();
|
|
7443
|
-
cli.version("2.
|
|
7623
|
+
cli.version("2.5.0");
|
|
7444
7624
|
cli.parse();
|
|
7445
7625
|
//# sourceMappingURL=cli.cjs.map
|