weapp-vite 1.2.2 → 1.2.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.
@@ -3,7 +3,7 @@ import logger from "@weapp-core/logger";
3
3
  var logger_default = logger;
4
4
 
5
5
  // package.json
6
- var version = "1.2.2";
6
+ var version = "1.2.3";
7
7
 
8
8
  // src/constants.ts
9
9
  var VERSION = version;
@@ -16,6 +16,7 @@ import { addExtension as addExtension3, defu as defu3, removeExtension as remove
16
16
  import { watch } from "chokidar";
17
17
  import fs4 from "fs-extra";
18
18
  import path5 from "pathe";
19
+ import { build as tsupBuild } from "tsup";
19
20
  import { build, loadConfigFromFile } from "vite";
20
21
  import tsconfigPaths from "vite-tsconfig-paths";
21
22
 
@@ -736,7 +737,8 @@ var CompilerContext = class _CompilerContext {
736
737
  // miniprogram_dist
737
738
  // miniprogram
738
739
  // https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%9B%B8%E5%85%B3%E7%A4%BA%E4%BE%8B
739
- async buildNpm() {
740
+ async buildNpm(options) {
741
+ const { sourcemap } = defu3(options, { sourcemap: true });
740
742
  let packNpmRelationList = [];
741
743
  if (this.projectConfig.setting?.packNpmManually && Array.isArray(this.projectConfig.setting.packNpmRelationList)) {
742
744
  packNpmRelationList = this.projectConfig.setting.packNpmRelationList;
@@ -769,25 +771,20 @@ var CompilerContext = class _CompilerContext {
769
771
  path5.join(outDir, dep)
770
772
  );
771
773
  } else {
772
- await build({
773
- build: {
774
- sourcemap: true,
775
- outDir: path5.join(outDir, dep),
776
- minify: false,
777
- rollupOptions: {
778
- input: {
779
- index: require2.resolve(dep)
780
- },
781
- output: {
782
- format: "cjs",
783
- strict: false,
784
- entryFileNames: "[name].js"
785
- }
786
- // logLevel: 'silent',
787
- },
788
- assetsDir: "."
774
+ await tsupBuild({
775
+ entry: {
776
+ index: require2.resolve(dep)
789
777
  },
790
- logLevel: "error"
778
+ format: ["cjs"],
779
+ outDir: path5.join(outDir, dep),
780
+ silent: true,
781
+ shims: true,
782
+ outExtension: () => {
783
+ return {
784
+ js: ".js"
785
+ };
786
+ },
787
+ sourcemap
791
788
  });
792
789
  }
793
790
  logger_default.success(`${dep} \u4F9D\u8D56\u5904\u7406\u5B8C\u6210!`);
package/dist/cli.cjs CHANGED
@@ -33,7 +33,7 @@ var import_cac = require("cac");
33
33
  var import_weapp_ide_cli = require("weapp-ide-cli");
34
34
 
35
35
  // package.json
36
- var version = "1.2.2";
36
+ var version = "1.2.3";
37
37
 
38
38
  // src/constants.ts
39
39
  var VERSION = version;
@@ -46,6 +46,7 @@ var import_shared4 = require("@weapp-core/shared");
46
46
  var import_chokidar = require("chokidar");
47
47
  var import_fs_extra4 = __toESM(require("fs-extra"), 1);
48
48
  var import_pathe5 = __toESM(require("pathe"), 1);
49
+ var import_tsup = require("tsup");
49
50
  var import_vite2 = require("vite");
50
51
  var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
51
52
 
@@ -770,7 +771,8 @@ var CompilerContext = class _CompilerContext {
770
771
  // miniprogram_dist
771
772
  // miniprogram
772
773
  // https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%9B%B8%E5%85%B3%E7%A4%BA%E4%BE%8B
773
- async buildNpm() {
774
+ async buildNpm(options) {
775
+ const { sourcemap } = (0, import_shared4.defu)(options, { sourcemap: true });
774
776
  let packNpmRelationList = [];
775
777
  if (this.projectConfig.setting?.packNpmManually && Array.isArray(this.projectConfig.setting.packNpmRelationList)) {
776
778
  packNpmRelationList = this.projectConfig.setting.packNpmRelationList;
@@ -803,25 +805,20 @@ var CompilerContext = class _CompilerContext {
803
805
  import_pathe5.default.join(outDir, dep)
804
806
  );
805
807
  } else {
806
- await (0, import_vite2.build)({
807
- build: {
808
- sourcemap: true,
809
- outDir: import_pathe5.default.join(outDir, dep),
810
- minify: false,
811
- rollupOptions: {
812
- input: {
813
- index: require2.resolve(dep)
814
- },
815
- output: {
816
- format: "cjs",
817
- strict: false,
818
- entryFileNames: "[name].js"
819
- }
820
- // logLevel: 'silent',
821
- },
822
- assetsDir: "."
808
+ await (0, import_tsup.build)({
809
+ entry: {
810
+ index: require2.resolve(dep)
823
811
  },
824
- logLevel: "error"
812
+ format: ["cjs"],
813
+ outDir: import_pathe5.default.join(outDir, dep),
814
+ silent: true,
815
+ shims: true,
816
+ outExtension: () => {
817
+ return {
818
+ js: ".js"
819
+ };
820
+ },
821
+ sourcemap
825
822
  });
826
823
  }
827
824
  logger_default.success(`${dep} \u4F9D\u8D56\u5904\u7406\u5B8C\u6210!`);
@@ -851,7 +848,7 @@ function convertBase(v) {
851
848
  cli.option("-c, --config <file>", `[string] use specified config file`).option("--base <path>", `[string] public base path (default: /)`, {
852
849
  type: [convertBase]
853
850
  }).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option("-d, --debug [feat]", `[string | boolean] show debug logs`).option("-f, --filter <filter>", `[string] filter debug logs`).option("-m, --mode <mode>", `[string] set env mode`);
854
- cli.command("[root]", "start dev server").alias("serve").alias("dev").action(async (root, options) => {
851
+ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).action(async (root, options) => {
855
852
  filterDuplicateOptions(options);
856
853
  const ctx = new CompilerContext({
857
854
  cwd: root,
@@ -859,7 +856,9 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").action(asy
859
856
  isDev: true
860
857
  });
861
858
  await ctx.loadDefaultConfig();
862
- await ctx.buildNpm();
859
+ if (!options.skipNpm) {
860
+ await ctx.buildNpm();
861
+ }
863
862
  await ctx.runDev();
864
863
  });
865
864
  cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option(
@@ -871,7 +870,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
871
870
  ).option(
872
871
  "--emptyOutDir",
873
872
  `[boolean] force empty outDir when it's outside of root`
874
- ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
873
+ ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).action(async (root, options) => {
875
874
  filterDuplicateOptions(options);
876
875
  const ctx = new CompilerContext({
877
876
  cwd: root,
@@ -879,7 +878,9 @@ cli.command("build [root]", "build for production").option("--target <target>",
879
878
  });
880
879
  await ctx.loadDefaultConfig();
881
880
  await ctx.runProd();
882
- await ctx.buildNpm();
881
+ if (!options.skipNpm) {
882
+ await ctx.buildNpm({ sourcemap: false });
883
+ }
883
884
  });
884
885
  cli.command("init").action(() => {
885
886
  try {
package/dist/cli.mjs CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  CompilerContext,
3
3
  VERSION,
4
4
  logger_default
5
- } from "./chunk-NP647U5Z.mjs";
5
+ } from "./chunk-MFE5RFWP.mjs";
6
6
  import "./chunk-444MQSSG.mjs";
7
7
 
8
8
  // src/cli.ts
@@ -27,7 +27,7 @@ function convertBase(v) {
27
27
  cli.option("-c, --config <file>", `[string] use specified config file`).option("--base <path>", `[string] public base path (default: /)`, {
28
28
  type: [convertBase]
29
29
  }).option("-l, --logLevel <level>", `[string] info | warn | error | silent`).option("--clearScreen", `[boolean] allow/disable clear screen when logging`).option("-d, --debug [feat]", `[string | boolean] show debug logs`).option("-f, --filter <filter>", `[string] filter debug logs`).option("-m, --mode <mode>", `[string] set env mode`);
30
- cli.command("[root]", "start dev server").alias("serve").alias("dev").action(async (root, options) => {
30
+ cli.command("[root]", "start dev server").alias("serve").alias("dev").option("--skipNpm", `[boolean] if skip npm build`).action(async (root, options) => {
31
31
  filterDuplicateOptions(options);
32
32
  const ctx = new CompilerContext({
33
33
  cwd: root,
@@ -35,7 +35,9 @@ cli.command("[root]", "start dev server").alias("serve").alias("dev").action(asy
35
35
  isDev: true
36
36
  });
37
37
  await ctx.loadDefaultConfig();
38
- await ctx.buildNpm();
38
+ if (!options.skipNpm) {
39
+ await ctx.buildNpm();
40
+ }
39
41
  await ctx.runDev();
40
42
  });
41
43
  cli.command("build [root]", "build for production").option("--target <target>", `[string] transpile target (default: 'modules')`).option("--outDir <dir>", `[string] output directory (default: dist)`).option(
@@ -47,7 +49,7 @@ cli.command("build [root]", "build for production").option("--target <target>",
47
49
  ).option(
48
50
  "--emptyOutDir",
49
51
  `[boolean] force empty outDir when it's outside of root`
50
- ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).action(async (root, options) => {
52
+ ).option("-w, --watch", `[boolean] rebuilds when modules have changed on disk`).option("--skipNpm", `[boolean] if skip npm build`).action(async (root, options) => {
51
53
  filterDuplicateOptions(options);
52
54
  const ctx = new CompilerContext({
53
55
  cwd: root,
@@ -55,7 +57,9 @@ cli.command("build [root]", "build for production").option("--target <target>",
55
57
  });
56
58
  await ctx.loadDefaultConfig();
57
59
  await ctx.runProd();
58
- await ctx.buildNpm();
60
+ if (!options.skipNpm) {
61
+ await ctx.buildNpm({ sourcemap: false });
62
+ }
59
63
  });
60
64
  cli.command("init").action(() => {
61
65
  try {
package/dist/index.cjs CHANGED
@@ -45,6 +45,7 @@ var import_shared4 = require("@weapp-core/shared");
45
45
  var import_chokidar = require("chokidar");
46
46
  var import_fs_extra4 = __toESM(require("fs-extra"), 1);
47
47
  var import_pathe5 = __toESM(require("pathe"), 1);
48
+ var import_tsup = require("tsup");
48
49
  var import_vite2 = require("vite");
49
50
  var import_vite_tsconfig_paths = __toESM(require("vite-tsconfig-paths"), 1);
50
51
 
@@ -772,7 +773,8 @@ var CompilerContext = class _CompilerContext {
772
773
  // miniprogram_dist
773
774
  // miniprogram
774
775
  // https://developers.weixin.qq.com/miniprogram/dev/devtools/npm.html#%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BB%84%E4%BB%B6%E7%9B%B8%E5%85%B3%E7%A4%BA%E4%BE%8B
775
- async buildNpm() {
776
+ async buildNpm(options) {
777
+ const { sourcemap } = (0, import_shared4.defu)(options, { sourcemap: true });
776
778
  let packNpmRelationList = [];
777
779
  if (this.projectConfig.setting?.packNpmManually && Array.isArray(this.projectConfig.setting.packNpmRelationList)) {
778
780
  packNpmRelationList = this.projectConfig.setting.packNpmRelationList;
@@ -805,25 +807,20 @@ var CompilerContext = class _CompilerContext {
805
807
  import_pathe5.default.join(outDir, dep)
806
808
  );
807
809
  } else {
808
- await (0, import_vite2.build)({
809
- build: {
810
- sourcemap: true,
811
- outDir: import_pathe5.default.join(outDir, dep),
812
- minify: false,
813
- rollupOptions: {
814
- input: {
815
- index: require2.resolve(dep)
816
- },
817
- output: {
818
- format: "cjs",
819
- strict: false,
820
- entryFileNames: "[name].js"
821
- }
822
- // logLevel: 'silent',
823
- },
824
- assetsDir: "."
810
+ await (0, import_tsup.build)({
811
+ entry: {
812
+ index: require2.resolve(dep)
825
813
  },
826
- logLevel: "error"
814
+ format: ["cjs"],
815
+ outDir: import_pathe5.default.join(outDir, dep),
816
+ silent: true,
817
+ shims: true,
818
+ outExtension: () => {
819
+ return {
820
+ js: ".js"
821
+ };
822
+ },
823
+ sourcemap
827
824
  });
828
825
  }
829
826
  logger_default.success(`${dep} \u4F9D\u8D56\u5904\u7406\u5B8C\u6210!`);
package/dist/index.d.cts CHANGED
@@ -48,7 +48,9 @@ declare class CompilerContext {
48
48
  runProd(): Promise<RollupOutput | RollupOutput[] | undefined>;
49
49
  build(): Promise<FSWatcher | undefined> | Promise<RollupOutput | RollupOutput[] | undefined>;
50
50
  loadDefaultConfig(): Promise<void>;
51
- buildNpm(): Promise<void>;
51
+ buildNpm(options?: {
52
+ sourcemap?: boolean;
53
+ }): Promise<void>;
52
54
  }
53
55
 
54
56
  export { CompilerContext, type CompilerContextOptions };
package/dist/index.d.ts CHANGED
@@ -48,7 +48,9 @@ declare class CompilerContext {
48
48
  runProd(): Promise<RollupOutput | RollupOutput[] | undefined>;
49
49
  build(): Promise<FSWatcher | undefined> | Promise<RollupOutput | RollupOutput[] | undefined>;
50
50
  loadDefaultConfig(): Promise<void>;
51
- buildNpm(): Promise<void>;
51
+ buildNpm(options?: {
52
+ sourcemap?: boolean;
53
+ }): Promise<void>;
52
54
  }
53
55
 
54
56
  export { CompilerContext, type CompilerContextOptions };
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  CompilerContext
3
- } from "./chunk-NP647U5Z.mjs";
3
+ } from "./chunk-MFE5RFWP.mjs";
4
4
  import "./chunk-444MQSSG.mjs";
5
5
  export {
6
6
  CompilerContext
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weapp-vite",
3
3
  "type": "module",
4
- "version": "1.2.2",
4
+ "version": "1.2.3",
5
5
  "description": "weapp-vite 一个现代化的小程序打包工具",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -53,6 +53,7 @@
53
53
  "cac": "^6.7.14",
54
54
  "chokidar": "^3.6.0",
55
55
  "debug": "^4.3.7",
56
+ "esbuild": "^0.24.0",
56
57
  "fast-glob": "^3.3.2",
57
58
  "fdir": "^6.3.0",
58
59
  "fs-extra": "^11.2.0",
@@ -62,10 +63,12 @@
62
63
  "pathe": "^1.1.2",
63
64
  "picocolors": "^1.1.0",
64
65
  "pkg-types": "^1.2.0",
66
+ "rollup": "^4.22.4",
67
+ "tsup": "^8.3.0",
65
68
  "vite-tsconfig-paths": "^5.0.1",
66
69
  "@weapp-core/init": "^1.0.4",
67
- "@weapp-core/logger": "^1.0.1",
68
70
  "@weapp-core/shared": "^1.0.1",
71
+ "@weapp-core/logger": "^1.0.1",
69
72
  "weapp-ide-cli": "^2.0.5"
70
73
  },
71
74
  "publishConfig": {