@dimina/compiler 1.0.14-beta.0 → 1.0.15

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { c as getPages, l as getTargetPath, n as getAppId, p as storeInfo, r as getAppName, s as getPageConfigInfo, t as getAppConfigInfo, u as getWorkPath, y as art_default } from "./env-DgCLbrQb.js";
1
+ import { c as getPages, l as getTargetPath, m as collectAssets, n as getAppId, p as storeInfo, r as getAppName, s as getPageConfigInfo, t as getAppConfigInfo, u as getWorkPath, y as art_default } from "./env-p9Az8lv5.js";
2
2
  import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { Worker } from "node:worker_threads";
@@ -270,12 +270,33 @@ var NpmBuilder = class {
270
270
  //#endregion
271
271
  //#region src/core/config-compiler.js
272
272
  /**
273
+ * 处理 tabBar.list 中的 iconPath / selectedIconPath。
274
+ * 视为相对小程序根目录的资源,复用 collectAssets 拷贝到 main/static/,
275
+ * 并把 list 中的路径改写成产物 URL,避免容器侧再做特殊解析。
276
+ *
277
+ * 注意:会在原 app 配置上原地修改,不影响后续输出(compileConfig 是
278
+ * 整个流水线最后才走到的环节,不会被再次读取)。
279
+ */
280
+ function processTabBarIcons(app) {
281
+ const list = app?.tabBar?.list;
282
+ if (!Array.isArray(list) || list.length === 0) return;
283
+ const workPath = getWorkPath();
284
+ const targetPath = getTargetPath();
285
+ const appId = getAppId();
286
+ for (const item of list) {
287
+ if (item.iconPath) item.iconPath = collectAssets(workPath, "", item.iconPath, targetPath, appId);
288
+ if (item.selectedIconPath) item.selectedIconPath = collectAssets(workPath, "", item.selectedIconPath, targetPath, appId);
289
+ }
290
+ }
291
+ /**
273
292
  *
274
293
  * 编译项目配置文件 app-config.json
275
294
  */
276
295
  function compileConfig() {
296
+ const app = getAppConfigInfo();
297
+ processTabBarIcons(app);
277
298
  const compileResInfo = {
278
- app: getAppConfigInfo(),
299
+ app,
279
300
  modules: getPageConfigInfo(),
280
301
  projectName: getAppName()
281
302
  };
@@ -293,7 +314,8 @@ var isPrinted = false;
293
314
  * @param {string} workPath 编译工作目录
294
315
  * @param {boolean} useAppIdDir 产物根目录是否包含appId
295
316
  */
296
- async function build(targetPath, workPath, useAppIdDir = true) {
317
+ async function build(targetPath, workPath, useAppIdDir = true, options = {}) {
318
+ const { sourcemap = false } = options;
297
319
  if (!isPrinted) {
298
320
  art_default();
299
321
  isPrinted = true;
@@ -337,13 +359,13 @@ async function build(targetPath, workPath, useAppIdDir = true) {
337
359
  {
338
360
  title: "编译页面文件",
339
361
  task: async (ctx, task) => {
340
- return runCompileInWorker("view", ctx, task);
362
+ return runCompileInWorker("view", ctx, task, { sourcemap });
341
363
  }
342
364
  },
343
365
  {
344
366
  title: "编译页面逻辑",
345
367
  task: async (ctx, task) => {
346
- return runCompileInWorker("logic", ctx, task);
368
+ return runCompileInWorker("logic", ctx, task, { sourcemap });
347
369
  }
348
370
  },
349
371
  {
@@ -353,7 +375,7 @@ async function build(targetPath, workPath, useAppIdDir = true) {
353
375
  path: "app",
354
376
  id: ""
355
377
  });
356
- return runCompileInWorker("style", ctx, task);
378
+ return runCompileInWorker("style", ctx, task, { sourcemap });
357
379
  }
358
380
  }
359
381
  ], { concurrent: true });
@@ -377,7 +399,7 @@ async function build(targetPath, workPath, useAppIdDir = true) {
377
399
  console.error(`${workPath} 编译出错: ${e.message}\n${e.stack}`);
378
400
  }
379
401
  }
380
- function runCompileInWorker(script, ctx, task) {
402
+ function runCompileInWorker(script, ctx, task, options = {}) {
381
403
  return workerPool.runWorker(() => new Promise((resolve, reject) => {
382
404
  const worker = new Worker(path.join(path.dirname(fileURLToPath(import.meta.url)), `core/${script}-compiler.js`), workerPool.getWorkerOptions());
383
405
  const totalTasks = Object.keys(ctx.pages.mainPages).length + Object.values(ctx.pages.subPages).reduce((sum, item) => sum + item.info.length, 0);
@@ -391,7 +413,8 @@ function runCompileInWorker(script, ctx, task) {
391
413
  };
392
414
  worker.postMessage({
393
415
  pages: ctx.pages,
394
- storeInfo: ctx.storeInfo
416
+ storeInfo: ctx.storeInfo,
417
+ sourcemap: !!options.sourcemap
395
418
  });
396
419
  worker.on("message", (message) => {
397
420
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimina/compiler",
3
- "version": "1.0.14-beta.0",
3
+ "version": "1.0.15",
4
4
  "description": "星河编译工具",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",
@@ -30,10 +30,14 @@
30
30
  "dmcc": "dist/bin/index.js"
31
31
  },
32
32
  "scripts": {
33
+ "prebuild": "node scripts/sync-compatibility-reference.js",
33
34
  "build": "vite build",
35
+ "sync:compat": "node scripts/sync-compatibility-reference.js",
36
+ "pretest": "node scripts/sync-compatibility-reference.js",
34
37
  "test": "vitest run",
35
38
  "test:dev": "vitest",
36
39
  "coverage": "vitest run --coverage",
40
+ "prepack": "npm run build",
37
41
  "release:beta": "npm version prerelease --preid=beta && npm publish --tag beta",
38
42
  "release": "npm version patch && npm publish"
39
43
  },
@@ -47,29 +51,23 @@
47
51
  "星河"
48
52
  ],
49
53
  "dependencies": {
50
- "@babel/core": "^7.29.0",
51
- "@babel/generator": "^7.29.1",
52
- "@babel/plugin-transform-modules-commonjs": "^7.28.6",
53
- "@babel/traverse": "^7.29.0",
54
- "@babel/types": "^7.29.0",
55
- "@vue/compiler-sfc": "^3.5.32",
56
- "autoprefixer": "^10.4.27",
54
+ "@vue/compiler-sfc": "^3.5.34",
55
+ "autoprefixer": "^10.5.0",
57
56
  "cheerio": "^1.2.0",
58
57
  "chokidar": "^4.0.3",
59
58
  "commander": "^14.0.3",
60
- "cssnano": "^7.1.4",
61
- "esbuild": "^0.27.7",
62
- "htmlparser2": "^10.1.0",
59
+ "cssnano": "^8.0.1",
60
+ "esbuild": "^0.28.0",
61
+ "htmlparser2": "^12.0.0",
63
62
  "less": "^4.6.4",
64
63
  "listr2": "^9.0.5",
65
64
  "magic-string": "^0.30.21",
66
- "oxc-parser": "^0.123.0",
67
- "oxc-transform": "^0.124.0",
65
+ "oxc-parser": "^0.129.0",
68
66
  "oxc-walker": "^0.7.0",
69
- "postcss": "^8.5.9",
67
+ "postcss": "^8.5.14",
70
68
  "postcss-selector-parser": "^7.1.1",
71
69
  "sass": "^1.99.0",
72
- "typescript": "^6.0.2"
70
+ "source-map-js": "^1.2.1"
73
71
  },
74
72
  "publishConfig": {
75
73
  "registry": "https://registry.npmjs.org/",