@weapp-core/init 3.0.1 → 3.0.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.
Files changed (44) hide show
  1. package/dist/index.cjs +116 -51
  2. package/dist/index.d.cts +32 -10
  3. package/dist/index.d.ts +32 -10
  4. package/dist/index.js +114 -49
  5. package/package.json +1 -1
  6. package/templates/default/auto-import-components.json +3 -0
  7. package/templates/default/gitignore +2 -1
  8. package/templates/default/package.json +2 -2
  9. package/templates/default/project.private.config.json +1 -1
  10. package/templates/default/src/components/HelloWorld/HelloWorld.json +1 -1
  11. package/templates/default/src/components/HelloWorld/HelloWorld.ts +1 -0
  12. package/templates/default/src/pages/index/index.ts +1 -0
  13. package/templates/default/tsconfig.app.json +55 -0
  14. package/templates/default/tsconfig.json +4 -41
  15. package/templates/default/tsconfig.node.json +23 -3
  16. package/templates/tailwindcss/auto-import-components.json +3 -0
  17. package/templates/tailwindcss/gitignore +2 -1
  18. package/templates/tailwindcss/package.json +5 -5
  19. package/templates/tailwindcss/project.config.json +1 -1
  20. package/templates/tailwindcss/project.private.config.json +1 -1
  21. package/templates/tailwindcss/src/components/HelloWorld/HelloWorld.ts +1 -0
  22. package/templates/tailwindcss/src/pages/index/index.ts +2 -0
  23. package/templates/tailwindcss/src/pages/profile/index.ts +1 -0
  24. package/templates/tailwindcss/tsconfig.app.json +55 -0
  25. package/templates/tailwindcss/tsconfig.json +4 -41
  26. package/templates/tailwindcss/tsconfig.node.json +23 -3
  27. package/templates/tdesign/gitignore +2 -1
  28. package/templates/tdesign/package.json +6 -6
  29. package/templates/tdesign/project.config.json +3 -2
  30. package/templates/tdesign/src/components/HelloWorld/HelloWorld.ts +1 -0
  31. package/templates/tdesign/src/pages/index/index.ts +3 -0
  32. package/templates/tdesign/tsconfig.app.json +58 -0
  33. package/templates/tdesign/tsconfig.json +4 -42
  34. package/templates/tdesign/tsconfig.node.json +23 -3
  35. package/templates/tdesign/vite.config.ts +2 -4
  36. package/templates/vant/gitignore +2 -1
  37. package/templates/vant/package.json +5 -5
  38. package/templates/vant/project.config.json +1 -1
  39. package/templates/vant/src/components/HelloWorld/HelloWorld.ts +1 -0
  40. package/templates/vant/src/pages/index/index.ts +2 -0
  41. package/templates/vant/tsconfig.app.json +58 -0
  42. package/templates/vant/tsconfig.json +4 -44
  43. package/templates/vant/tsconfig.node.json +23 -3
  44. package/templates/vant/vite.config.ts +2 -4
package/dist/index.cjs CHANGED
@@ -42,8 +42,8 @@ __export(index_exports, {
42
42
  });
43
43
  module.exports = __toCommonJS(index_exports);
44
44
 
45
- // ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.13.19_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
46
- var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
45
+ // ../../node_modules/.pnpm/tsup@8.5.1_@swc+core@1.15.1_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
46
+ var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
47
47
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
48
48
 
49
49
  // src/index.ts
@@ -477,6 +477,7 @@ function createContext() {
477
477
  packageJson: createDocument(),
478
478
  viteConfig: createDocument(),
479
479
  tsconfig: createDocument(),
480
+ tsconfigApp: createDocument(),
480
481
  tsconfigNode: createDocument(),
481
482
  dts: createDocument()
482
483
  };
@@ -497,28 +498,59 @@ function resetContext() {
497
498
  Object.assign(ctx.packageJson, next.packageJson);
498
499
  Object.assign(ctx.viteConfig, next.viteConfig);
499
500
  Object.assign(ctx.tsconfig, next.tsconfig);
501
+ Object.assign(ctx.tsconfigApp, next.tsconfigApp);
500
502
  Object.assign(ctx.tsconfigNode, next.tsconfigNode);
501
503
  Object.assign(ctx.dts, next.dts);
502
504
  }
503
505
 
504
506
  // src/tsconfigJson.ts
507
+ var srcIncludeGlobs = [
508
+ "src/**/*.ts",
509
+ "src/**/*.tsx",
510
+ "src/**/*.js",
511
+ "src/**/*.jsx",
512
+ "src/**/*.mts",
513
+ "src/**/*.cts",
514
+ "src/**/*.vue",
515
+ "src/**/*.json",
516
+ "src/**/*.d.ts",
517
+ "types/**/*.d.ts",
518
+ "env.d.ts"
519
+ ];
505
520
  function getDefaultTsconfigJson() {
521
+ return {
522
+ references: [
523
+ {
524
+ path: "./tsconfig.app.json"
525
+ },
526
+ {
527
+ path: "./tsconfig.node.json"
528
+ }
529
+ ],
530
+ files: []
531
+ };
532
+ }
533
+ function getDefaultTsconfigAppJson() {
506
534
  return {
507
535
  compilerOptions: {
508
- target: "ES2020",
509
- jsx: "preserve",
536
+ tsBuildInfoFile: "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
537
+ target: "ES2023",
510
538
  lib: [
511
- "ES2020",
539
+ "ES2023",
512
540
  "DOM",
513
541
  "DOM.Iterable"
514
542
  ],
515
- useDefineForClassFields: false,
516
- baseUrl: ".",
543
+ jsx: "preserve",
517
544
  module: "ESNext",
518
545
  moduleResolution: "bundler",
546
+ moduleDetection: "force",
547
+ baseUrl: ".",
519
548
  paths: {
520
549
  "@/*": [
521
- "./*"
550
+ "./src/*"
551
+ ],
552
+ "take:@/*": [
553
+ "./src/*"
522
554
  ]
523
555
  },
524
556
  resolveJsonModule: true,
@@ -527,41 +559,60 @@ function getDefaultTsconfigJson() {
527
559
  ],
528
560
  allowImportingTsExtensions: true,
529
561
  allowJs: true,
562
+ allowSyntheticDefaultImports: true,
563
+ esModuleInterop: true,
564
+ isolatedModules: true,
530
565
  strict: true,
531
566
  noFallthroughCasesInSwitch: true,
532
567
  noUnusedLocals: true,
533
568
  noUnusedParameters: true,
534
569
  noEmit: true,
535
- isolatedModules: true,
570
+ verbatimModuleSyntax: true,
571
+ noUncheckedSideEffectImports: true,
572
+ erasableSyntaxOnly: true,
536
573
  skipLibCheck: true
537
574
  },
538
- references: [
539
- {
540
- path: "./tsconfig.node.json"
541
- }
542
- ],
543
- include: [
544
- "**/*.ts",
545
- "**/*.js",
546
- "vite-env.d.ts"
547
- ],
548
- exclude: [
549
- "node_modules",
550
- "dist"
551
- ]
575
+ include: srcIncludeGlobs
552
576
  };
553
577
  }
554
578
  function getDefaultTsconfigNodeJson(include = []) {
579
+ const baseInclude = [
580
+ "vite.config.ts",
581
+ "vite.config.*.ts",
582
+ "*.config.ts",
583
+ "config/**/*.ts",
584
+ "scripts/**/*.ts"
585
+ ];
586
+ const mergedInclude = Array.from(/* @__PURE__ */ new Set([
587
+ ...baseInclude,
588
+ ...include
589
+ ]));
555
590
  return {
556
591
  compilerOptions: {
557
- composite: true,
592
+ tsBuildInfoFile: "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
593
+ target: "ES2023",
594
+ lib: [
595
+ "ES2023"
596
+ ],
558
597
  module: "ESNext",
559
598
  moduleResolution: "bundler",
599
+ moduleDetection: "force",
600
+ types: [
601
+ "node"
602
+ ],
603
+ allowImportingTsExtensions: true,
604
+ resolveJsonModule: true,
605
+ verbatimModuleSyntax: true,
560
606
  strict: true,
561
- allowSyntheticDefaultImports: true,
607
+ noFallthroughCasesInSwitch: true,
608
+ noUnusedLocals: true,
609
+ noUnusedParameters: true,
610
+ noEmit: true,
611
+ noUncheckedSideEffectImports: true,
612
+ erasableSyntaxOnly: true,
562
613
  skipLibCheck: true
563
614
  },
564
- include
615
+ include: mergedInclude
565
616
  };
566
617
  }
567
618
 
@@ -573,23 +624,39 @@ function getDefaultTsDts() {
573
624
 
574
625
  // src/utils/fs.ts
575
626
  var import_fs_extra = __toESM(require("fs-extra"), 1);
627
+ var FsReadError = class extends Error {
628
+ constructor(filepath, cause) {
629
+ super(`Failed to read ${filepath}`);
630
+ this.filepath = filepath;
631
+ this.cause = cause;
632
+ this.name = "FsReadError";
633
+ }
634
+ };
635
+ var FsWriteError = class extends Error {
636
+ constructor(filepath, cause) {
637
+ super(`Failed to write ${filepath}`);
638
+ this.filepath = filepath;
639
+ this.cause = cause;
640
+ this.name = "FsWriteError";
641
+ }
642
+ };
576
643
  async function readJsonIfExists(filepath) {
577
644
  try {
578
- if (!await import_fs_extra.default.pathExists(filepath)) {
579
- return null;
580
- }
581
645
  return await import_fs_extra.default.readJSON(filepath);
582
646
  } catch (error) {
647
+ if (error?.code === "ENOENT") {
648
+ return null;
649
+ }
583
650
  throw new FsReadError(filepath, error);
584
651
  }
585
652
  }
586
653
  async function readFileIfExists(filepath) {
587
654
  try {
588
- if (!await import_fs_extra.default.pathExists(filepath)) {
589
- return null;
590
- }
591
655
  return await import_fs_extra.default.readFile(filepath, "utf8");
592
656
  } catch (error) {
657
+ if (error?.code === "ENOENT") {
658
+ return null;
659
+ }
593
660
  throw new FsReadError(filepath, error);
594
661
  }
595
662
  }
@@ -609,22 +676,6 @@ async function writeFile(filepath, contents) {
609
676
  throw new FsWriteError(filepath, error);
610
677
  }
611
678
  }
612
- var FsReadError = class extends Error {
613
- constructor(filepath, cause) {
614
- super(`Failed to read ${filepath}`);
615
- this.filepath = filepath;
616
- this.cause = cause;
617
- this.name = "FsReadError";
618
- }
619
- };
620
- var FsWriteError = class extends Error {
621
- constructor(filepath, cause) {
622
- super(`Failed to write ${filepath}`);
623
- this.filepath = filepath;
624
- this.cause = cause;
625
- this.name = "FsWriteError";
626
- }
627
- };
628
679
 
629
680
  // src/utils/path.ts
630
681
  function resolveOutputPath(root, dest, fallback) {
@@ -678,22 +729,35 @@ async function initTsJsonFiles(options) {
678
729
  const { root, dest, write = true } = options;
679
730
  const tsJsonFilename = ctx.tsconfig.name = "tsconfig.json";
680
731
  const tsJsonFilePath = ctx.tsconfig.path = posix.resolve(root, tsJsonFilename);
732
+ const tsAppJsonFilename = ctx.tsconfigApp.name = "tsconfig.app.json";
733
+ const tsAppJsonFilePath = ctx.tsconfigApp.path = posix.resolve(root, tsAppJsonFilename);
681
734
  const tsNodeJsonFilename = ctx.tsconfigNode.name = "tsconfig.node.json";
682
735
  const tsNodeJsonFilePath = ctx.tsconfigNode.path = posix.resolve(root, tsNodeJsonFilename);
683
736
  const tsconfig = getDefaultTsconfigJson();
737
+ const tsconfigApp = getDefaultTsconfigAppJson();
684
738
  const includeFiles = ctx.viteConfig.name ? [ctx.viteConfig.name] : [];
685
739
  const tsconfigNode = getDefaultTsconfigNodeJson(includeFiles);
686
740
  ctx.tsconfig.value = tsconfig;
741
+ ctx.tsconfigApp.value = tsconfigApp;
687
742
  ctx.tsconfigNode.value = tsconfigNode;
688
743
  if (write) {
689
744
  const tsconfigOutputPath = resolveOutputPath(root, dest, tsJsonFilePath);
690
- const tsconfigNodeOutputPath = tsNodeJsonFilePath;
745
+ const tsconfigAppOutputPath = resolveOutputPath(root, dest, tsAppJsonFilePath);
746
+ const tsconfigNodeOutputPath = resolveOutputPath(root, dest, tsNodeJsonFilePath);
691
747
  await writeJsonFile(tsconfigOutputPath, tsconfig);
748
+ await writeJsonFile(tsconfigAppOutputPath, tsconfigApp);
692
749
  await writeJsonFile(tsconfigNodeOutputPath, tsconfigNode);
693
- import_logger.default.log(`\u2728 \u5199\u5165 ${posix.relative(root, tsconfigOutputPath)} \u4E0E ${posix.relative(root, tsconfigNodeOutputPath)} \u6210\u529F!`);
750
+ import_logger.default.log(
751
+ `\u2728 \u5199\u5165 ${[
752
+ posix.relative(root, tsconfigOutputPath),
753
+ posix.relative(root, tsconfigAppOutputPath),
754
+ posix.relative(root, tsconfigNodeOutputPath)
755
+ ].join(", ")} \u6210\u529F!`
756
+ );
694
757
  }
695
758
  return {
696
759
  tsconfig,
760
+ tsconfigApp,
697
761
  tsconfigNode
698
762
  };
699
763
  }
@@ -704,7 +768,7 @@ var import_logger3 = __toESM(require("@weapp-core/logger"), 1);
704
768
  var import_fs_extra2 = __toESM(require("fs-extra"), 1);
705
769
 
706
770
  // ../../packages/weapp-vite/package.json
707
- var version = "5.2.1";
771
+ var version = "5.9.3";
708
772
 
709
773
  // src/enums.ts
710
774
  var TemplateName = /* @__PURE__ */ ((TemplateName2) => {
@@ -792,6 +856,7 @@ yarn-error.log*
792
856
 
793
857
  dist
794
858
  dist-plugin
859
+ dist-web
795
860
  vite.config.ts.timestamp-*.mjs`;
796
861
  function mergeGitignore(existing) {
797
862
  const normalizedExisting = normalizeLineEndings(existing ?? "");
package/dist/index.d.cts CHANGED
@@ -39,6 +39,7 @@ interface Context {
39
39
  packageJson: ContextDocument<PackageJson>;
40
40
  viteConfig: ContextDocument<string>;
41
41
  tsconfig: ContextDocument<TSConfig>;
42
+ tsconfigApp: ContextDocument<TSConfig>;
42
43
  tsconfigNode: ContextDocument<TSConfig>;
43
44
  dts: ContextDocument<string>;
44
45
  }
@@ -47,42 +48,63 @@ declare function initViteConfigFile(options: SharedUpdateOptions): Promise<strin
47
48
  declare function initTsDtsFile(options: SharedUpdateOptions): Promise<string>;
48
49
  declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
49
50
  tsconfig: {
51
+ references: {
52
+ path: string;
53
+ }[];
54
+ files: never[];
55
+ };
56
+ tsconfigApp: {
50
57
  compilerOptions: {
58
+ tsBuildInfoFile: string;
51
59
  target: string;
52
- jsx: string;
53
60
  lib: string[];
54
- useDefineForClassFields: boolean;
55
- baseUrl: string;
61
+ jsx: string;
56
62
  module: string;
57
63
  moduleResolution: string;
64
+ moduleDetection: string;
65
+ baseUrl: string;
58
66
  paths: {
59
67
  '@/*': string[];
68
+ 'take:@/*': string[];
60
69
  };
61
70
  resolveJsonModule: boolean;
62
71
  types: string[];
63
72
  allowImportingTsExtensions: boolean;
64
73
  allowJs: boolean;
74
+ allowSyntheticDefaultImports: boolean;
75
+ esModuleInterop: boolean;
76
+ isolatedModules: boolean;
65
77
  strict: boolean;
66
78
  noFallthroughCasesInSwitch: boolean;
67
79
  noUnusedLocals: boolean;
68
80
  noUnusedParameters: boolean;
69
81
  noEmit: boolean;
70
- isolatedModules: boolean;
82
+ verbatimModuleSyntax: boolean;
83
+ noUncheckedSideEffectImports: boolean;
84
+ erasableSyntaxOnly: boolean;
71
85
  skipLibCheck: boolean;
72
86
  };
73
- references: {
74
- path: string;
75
- }[];
76
87
  include: string[];
77
- exclude: string[];
78
88
  };
79
89
  tsconfigNode: {
80
90
  compilerOptions: {
81
- composite: boolean;
91
+ tsBuildInfoFile: string;
92
+ target: string;
93
+ lib: string[];
82
94
  module: string;
83
95
  moduleResolution: string;
96
+ moduleDetection: string;
97
+ types: string[];
98
+ allowImportingTsExtensions: boolean;
99
+ resolveJsonModule: boolean;
100
+ verbatimModuleSyntax: boolean;
84
101
  strict: boolean;
85
- allowSyntheticDefaultImports: boolean;
102
+ noFallthroughCasesInSwitch: boolean;
103
+ noUnusedLocals: boolean;
104
+ noUnusedParameters: boolean;
105
+ noEmit: boolean;
106
+ noUncheckedSideEffectImports: boolean;
107
+ erasableSyntaxOnly: boolean;
86
108
  skipLibCheck: boolean;
87
109
  };
88
110
  include: string[];
package/dist/index.d.ts CHANGED
@@ -39,6 +39,7 @@ interface Context {
39
39
  packageJson: ContextDocument<PackageJson>;
40
40
  viteConfig: ContextDocument<string>;
41
41
  tsconfig: ContextDocument<TSConfig>;
42
+ tsconfigApp: ContextDocument<TSConfig>;
42
43
  tsconfigNode: ContextDocument<TSConfig>;
43
44
  dts: ContextDocument<string>;
44
45
  }
@@ -47,42 +48,63 @@ declare function initViteConfigFile(options: SharedUpdateOptions): Promise<strin
47
48
  declare function initTsDtsFile(options: SharedUpdateOptions): Promise<string>;
48
49
  declare function initTsJsonFiles(options: SharedUpdateOptions): Promise<{
49
50
  tsconfig: {
51
+ references: {
52
+ path: string;
53
+ }[];
54
+ files: never[];
55
+ };
56
+ tsconfigApp: {
50
57
  compilerOptions: {
58
+ tsBuildInfoFile: string;
51
59
  target: string;
52
- jsx: string;
53
60
  lib: string[];
54
- useDefineForClassFields: boolean;
55
- baseUrl: string;
61
+ jsx: string;
56
62
  module: string;
57
63
  moduleResolution: string;
64
+ moduleDetection: string;
65
+ baseUrl: string;
58
66
  paths: {
59
67
  '@/*': string[];
68
+ 'take:@/*': string[];
60
69
  };
61
70
  resolveJsonModule: boolean;
62
71
  types: string[];
63
72
  allowImportingTsExtensions: boolean;
64
73
  allowJs: boolean;
74
+ allowSyntheticDefaultImports: boolean;
75
+ esModuleInterop: boolean;
76
+ isolatedModules: boolean;
65
77
  strict: boolean;
66
78
  noFallthroughCasesInSwitch: boolean;
67
79
  noUnusedLocals: boolean;
68
80
  noUnusedParameters: boolean;
69
81
  noEmit: boolean;
70
- isolatedModules: boolean;
82
+ verbatimModuleSyntax: boolean;
83
+ noUncheckedSideEffectImports: boolean;
84
+ erasableSyntaxOnly: boolean;
71
85
  skipLibCheck: boolean;
72
86
  };
73
- references: {
74
- path: string;
75
- }[];
76
87
  include: string[];
77
- exclude: string[];
78
88
  };
79
89
  tsconfigNode: {
80
90
  compilerOptions: {
81
- composite: boolean;
91
+ tsBuildInfoFile: string;
92
+ target: string;
93
+ lib: string[];
82
94
  module: string;
83
95
  moduleResolution: string;
96
+ moduleDetection: string;
97
+ types: string[];
98
+ allowImportingTsExtensions: boolean;
99
+ resolveJsonModule: boolean;
100
+ verbatimModuleSyntax: boolean;
84
101
  strict: boolean;
85
- allowSyntheticDefaultImports: boolean;
102
+ noFallthroughCasesInSwitch: boolean;
103
+ noUnusedLocals: boolean;
104
+ noUnusedParameters: boolean;
105
+ noEmit: boolean;
106
+ noUncheckedSideEffectImports: boolean;
107
+ erasableSyntaxOnly: boolean;
86
108
  skipLibCheck: boolean;
87
109
  };
88
110
  include: string[];