@nasti-toolchain/nasti 2.4.0 → 2.4.2

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 CHANGED
@@ -31,6 +31,8 @@
31
31
 
32
32
  ## Quick Start
33
33
 
34
+ Requires Node.js `^20.19.0` or `>=22.12.0`.
35
+
34
36
  ```bash
35
37
  # 安装
36
38
  npm install -D @nasti-toolchain/nasti
@@ -323,6 +325,17 @@ export default defineConfig({
323
325
  consumer: 'client',
324
326
  entry: 'src/index.ts',
325
327
  resolve: { conditions: ['lynx-main-thread', 'browser', 'import'] },
328
+ build: {
329
+ target: 'es2019',
330
+ // 保留 CSS 模块图与 chunk 所有权,但不生成浏览器副作用/文件。
331
+ css: { inject: false, emit: false },
332
+ },
333
+ vue: {
334
+ template: { compilerOptions: { whitespace: 'condense' } },
335
+ transformTemplate(source, context) {
336
+ return transformLynxTemplate(source, context.environmentName)
337
+ },
338
+ },
326
339
  },
327
340
  },
328
341
  plugins: [pluginVueLynxNative()],
@@ -334,11 +347,28 @@ Environment API 是 `conditionNames` 和 `mainFields` 的唯一高层配置入
334
347
  top-level `resolve`)。这些值会无条件覆盖
335
348
  `build.rolldownOptions.resolve.conditionNames` / `mainFields` 中的对应底层选项。
336
349
 
337
- 在生产构建的 bundle/finalizer 相关钩子(如 `generateBundle`、`buildEnd`、
338
- `closeBundle`)中,`this.environment` 会准确指向当前 BG/MT 环境。unbundled
339
- dev 调用路径可能不提供该对象,开发期插件不得依赖 `this.environment`;应使用
340
- Environment API 的显式环境参数。插件可登记结构化 manifest,并在 app 级
341
- finalizer 中直接查询 entry/artifact,最后写出聚合 bundle:
350
+ 生产与 dev 插件钩子的 `this.environment` 都会准确指向当前 BG/MT 环境。
351
+ 每个 client-consumer 环境拥有独立的 module graph、transform 缓存和命名 HMR
352
+ 通道;工具链可以调用 `server.transformEnvironmentRequest(name, url)`(或
353
+ `server.environments[name].transformRequest(url)`)取得特定环境的转换结果。
354
+ `handleHotUpdateApp` 在一个文件完成所有环境的失效与重转后只调用一次:
355
+
356
+ ```ts
357
+ const pluginVueLynxNative = () => ({
358
+ name: 'vue-lynx:native',
359
+
360
+ async handleHotUpdateApp({ environments }) {
361
+ for (const [name, update] of Object.entries(environments)) {
362
+ await reencodeAffectedSections(name, update.transformed)
363
+ }
364
+ },
365
+ })
366
+ ```
367
+
368
+ CSS 原文/转换结果可从 `environment.getCssModule(id)` /
369
+ `environment.getCssModules()` 读取,无需解析浏览器 `<style>` 注入代码。
370
+ 生产插件还可登记结构化 manifest,并在 app 级 finalizer 中直接查询
371
+ entry、chunk、CSS、asset 和 source map,最后写出聚合 bundle:
342
372
 
343
373
  ```ts
344
374
  const pluginVueLynxNative = () => ({
@@ -365,8 +395,11 @@ const pluginVueLynxNative = () => ({
365
395
  ```
366
396
 
367
397
  `build()` 的 `environmentResults` 会包含原生环境自动推导的 `entries`、插件登记的
368
- `manifest/stats` 及完整 `output`;app 级产物同时出现在 `BuildResult.appOutput`。
369
- 这些 API 只负责双线程编排与聚合,Vue SFC/worklet、Lynx CSS 和 encoder 由后续工具链插件实现。
398
+ `manifest/stats`、`chunks/assets/css/sourceMaps` 及完整 `output`;对应的
399
+ `BuildAppContext.getChunk/getCss/getSourceMap/resolvePublicPath` 可跨环境关联初始与
400
+ lazy chunk。app 级产物同时出现在 `BuildResult.appOutput`。高层
401
+ `environments.<name>.build.target` 会同时应用于 OXC 的 TS/JSX 转换和 Rolldown
402
+ 的最终输出,无需再设置底层 `rolldownOptions.transform.target`。
370
403
 
371
404
  ## Monaco Editor 支持
372
405