@dimina/compiler 1.0.12-beta.1 → 1.0.12-beta.3

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.
@@ -5,7 +5,7 @@ const process = require("node:process");
5
5
  const chokidar = require("chokidar");
6
6
  const commander = require("commander");
7
7
  const index = require("../index.cjs");
8
- const version = "1.0.12-beta.0";
8
+ const version = "1.0.12-beta.2";
9
9
  const pack = {
10
10
  version
11
11
  };
package/dist/bin/index.js CHANGED
@@ -4,7 +4,7 @@ import process from "node:process";
4
4
  import chokidar from "chokidar";
5
5
  import { program } from "commander";
6
6
  import build from "../index.js";
7
- const version = "1.0.12-beta.0";
7
+ const version = "1.0.12-beta.2";
8
8
  const pack = {
9
9
  version
10
10
  };
@@ -238,10 +238,11 @@ function buildJSByPath(packageName, module2, compileRes, mainCompileRes, addExtr
238
238
  compileInfo.code = code;
239
239
  }
240
240
  function getExtraInfoStatement(type, addedArgs) {
241
+ const propertyAssignment = types.objectProperty(types.identifier("__extraInfo"), addedArgs);
241
242
  const assignmentExpression = types.assignmentExpression(
242
243
  "=",
243
- types.memberExpression(types.identifier("globalThis"), types.identifier("__extraInfo")),
244
- addedArgs
244
+ types.memberExpression(types.identifier("globalThis"), propertyAssignment.key),
245
+ propertyAssignment.value
245
246
  );
246
247
  return types.expressionStatement(assignmentExpression);
247
248
  }
@@ -236,10 +236,11 @@ function buildJSByPath(packageName, module, compileRes, mainCompileRes, addExtra
236
236
  compileInfo.code = code;
237
237
  }
238
238
  function getExtraInfoStatement(type, addedArgs) {
239
+ const propertyAssignment = types.objectProperty(types.identifier("__extraInfo"), addedArgs);
239
240
  const assignmentExpression = types.assignmentExpression(
240
241
  "=",
241
- types.memberExpression(types.identifier("globalThis"), types.identifier("__extraInfo")),
242
- addedArgs
242
+ types.memberExpression(types.identifier("globalThis"), propertyAssignment.key),
243
+ propertyAssignment.value
243
244
  );
244
245
  return types.expressionStatement(assignmentExpression);
245
246
  }
@@ -357,7 +357,7 @@ function compileModule(module2, isComponent, scriptRes) {
357
357
  comments: false,
358
358
  sourceType: "script"
359
359
  }).code;
360
- tplComponents += `'${tm.path}':${code2.replace(/;$/, "")},`;
360
+ tplComponents += `'${tm.path}':${cleanCompiledCode(code2)},`;
361
361
  }
362
362
  tplComponents += "}";
363
363
  const tplAst = babel.parseSync(tplCode.code);
@@ -369,7 +369,7 @@ function compileModule(module2, isComponent, scriptRes) {
369
369
  const code = `Module({
370
370
  path: '${module2.path}',
371
371
  id: '${module2.id}',
372
- render: ${transCode.replace(/;$/, "")},
372
+ render: ${cleanCompiledCode(transCode)},
373
373
  usingComponents: ${JSON.stringify(module2.usingComponents)},
374
374
  tplComponents: ${tplComponents},
375
375
  });`;
@@ -574,7 +574,7 @@ function compileModuleWithAllWxs(module2, scriptRes, allScriptModules) {
574
574
  comments: false,
575
575
  sourceType: "script"
576
576
  }).code;
577
- tplComponents += `'${tm.path}':${code2.replace(/;$/, "").replace(/^"use strict";\s*/, "")},`;
577
+ tplComponents += `'${tm.path}':${cleanCompiledCode(code2)},`;
578
578
  }
579
579
  tplComponents += "}";
580
580
  const tplAst = babel.parseSync(tplCode.code);
@@ -586,7 +586,7 @@ function compileModuleWithAllWxs(module2, scriptRes, allScriptModules) {
586
586
  const code = `Module({
587
587
  path: '${module2.path}',
588
588
  id: '${module2.id}',
589
- render: ${transCode.replace(/;$/, "").replace(/^"use strict";\s*/, "")},
589
+ render: ${cleanCompiledCode(transCode)},
590
590
  usingComponents: ${JSON.stringify(module2.usingComponents)},
591
591
  tplComponents: ${tplComponents},
592
592
  });`;
@@ -656,6 +656,9 @@ function processIncludedFileWxsDependencies(content, includePath, scriptModule,
656
656
  }
657
657
  }
658
658
  }
659
+ function cleanCompiledCode(code) {
660
+ return code.replace(/;$/, "").replace(/^"use strict";\s*/, "");
661
+ }
659
662
  function toCompileTemplate(isComponent, path2, components, componentPlaceholder, processedPaths = /* @__PURE__ */ new Set()) {
660
663
  const workPath = env.getWorkPath();
661
664
  const fullPath = getViewPath(workPath, path2);
@@ -337,7 +337,7 @@ function compileModule(module, isComponent, scriptRes) {
337
337
  comments: false,
338
338
  sourceType: "script"
339
339
  }).code;
340
- tplComponents += `'${tm.path}':${code2.replace(/;$/, "")},`;
340
+ tplComponents += `'${tm.path}':${cleanCompiledCode(code2)},`;
341
341
  }
342
342
  tplComponents += "}";
343
343
  const tplAst = babel.parseSync(tplCode.code);
@@ -349,7 +349,7 @@ function compileModule(module, isComponent, scriptRes) {
349
349
  const code = `Module({
350
350
  path: '${module.path}',
351
351
  id: '${module.id}',
352
- render: ${transCode.replace(/;$/, "")},
352
+ render: ${cleanCompiledCode(transCode)},
353
353
  usingComponents: ${JSON.stringify(module.usingComponents)},
354
354
  tplComponents: ${tplComponents},
355
355
  });`;
@@ -554,7 +554,7 @@ function compileModuleWithAllWxs(module, scriptRes, allScriptModules) {
554
554
  comments: false,
555
555
  sourceType: "script"
556
556
  }).code;
557
- tplComponents += `'${tm.path}':${code2.replace(/;$/, "").replace(/^"use strict";\s*/, "")},`;
557
+ tplComponents += `'${tm.path}':${cleanCompiledCode(code2)},`;
558
558
  }
559
559
  tplComponents += "}";
560
560
  const tplAst = babel.parseSync(tplCode.code);
@@ -566,7 +566,7 @@ function compileModuleWithAllWxs(module, scriptRes, allScriptModules) {
566
566
  const code = `Module({
567
567
  path: '${module.path}',
568
568
  id: '${module.id}',
569
- render: ${transCode.replace(/;$/, "").replace(/^"use strict";\s*/, "")},
569
+ render: ${cleanCompiledCode(transCode)},
570
570
  usingComponents: ${JSON.stringify(module.usingComponents)},
571
571
  tplComponents: ${tplComponents},
572
572
  });`;
@@ -636,6 +636,9 @@ function processIncludedFileWxsDependencies(content, includePath, scriptModule,
636
636
  }
637
637
  }
638
638
  }
639
+ function cleanCompiledCode(code) {
640
+ return code.replace(/;$/, "").replace(/^"use strict";\s*/, "");
641
+ }
639
642
  function toCompileTemplate(isComponent, path2, components, componentPlaceholder, processedPaths = /* @__PURE__ */ new Set()) {
640
643
  const workPath = getWorkPath();
641
644
  const fullPath = getViewPath(workPath, path2);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimina/compiler",
3
- "version": "1.0.12-beta.1",
3
+ "version": "1.0.12-beta.3",
4
4
  "description": "星河编译工具",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.js",