@gct-paas/build 0.1.5-dev.2 → 0.1.5-dev.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,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.PROD_MODE = exports.DEV_MODE = exports.DEFAULT_EXTERNAL = void 0;
6
+ exports.PROD_MODE = exports.DEV_MODE = exports.DEFAULT_IGNORED_DEPENDENCIES = exports.DEFAULT_EXTERNAL = void 0;
7
7
  const DEV_MODE = exports.DEV_MODE = "development";
8
8
  const PROD_MODE = exports.PROD_MODE = "production";
9
- const DEFAULT_EXTERNAL = exports.DEFAULT_EXTERNAL = ["vue", "vue-router", "vue-i18n", "axios", "dayjs", "lodash-es", "qs", "pinia", "vuedraggable", "sortablejs", "vue-grid-layout", "vant", "ant-design-vue", "@gct-paas/build", "@gct-paas/api", "@gct-paas/core", "@gct-paas/core-mobile", "@gct-paas/core-web", "@gct-paas/core-pad", "@gct-paas/design", "@gct-paas/design-mobile", "@gct-paas/design-web", "@gct-paas/design-pad", "@gct-paas/mobile", "@gct-paas/scss", "@gct-paas/web", "@gct-paas/pad", "systemjs"];
9
+ const DEFAULT_EXTERNAL = exports.DEFAULT_EXTERNAL = ["vue", "vue-router", "vue-i18n", "axios", "dayjs", "lodash-es", "qs", "pinia", "vuedraggable", "sortablejs", "vue-grid-layout", "vant", "ant-design-vue", "@gct-paas/build", "@gct-paas/api", "@gct-paas/core", "@gct-paas/core-mobile", "@gct-paas/core-web", "@gct-paas/core-pad", "@gct-paas/design", "@gct-paas/design-mobile", "@gct-paas/design-web", "@gct-paas/design-pad", "@gct-paas/mobile", "@gct-paas/scss", "@gct-paas/web", "@gct-paas/pad", "systemjs"];
10
+ const DEFAULT_IGNORED_DEPENDENCIES = exports.DEFAULT_IGNORED_DEPENDENCIES = ["path-browserify", "qx-util"];
@@ -10,3 +10,7 @@ export declare const PROD_MODE = "production";
10
10
  * 默认需要忽略编译的外部依赖
11
11
  */
12
12
  export declare const DEFAULT_EXTERNAL: string[];
13
+ /**
14
+ * 默认忽略编译的依赖列表,用于 pkg 包开发编译时
15
+ */
16
+ export declare const DEFAULT_IGNORED_DEPENDENCIES: string[];
@@ -8,6 +8,7 @@ var _vite = require("vite");
8
8
  var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
9
9
  var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
10
10
  var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
11
+ var _viteTsconfigPaths = _interopRequireDefault(require("vite-tsconfig-paths"));
11
12
  var _path = _interopRequireDefault(require("path"));
12
13
  var _constants = require("../../constants/index.cjs");
13
14
  var _util = require("../../util/index.cjs");
@@ -29,7 +30,7 @@ function defineViteBaseConfig(opts = {}) {
29
30
  external: _constants.DEFAULT_EXTERNAL
30
31
  }
31
32
  },
32
- plugins: [(0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)()
33
+ plugins: [(0, _viteTsconfigPaths.default)(), (0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)()
33
34
  // 关系 babel 配置,这个配置要放在具体的 project vite 编译配置中,底包应该是干净的
34
35
  // babel({
35
36
  // babelHelpers: 'bundled',
@@ -11,9 +11,11 @@ var _pluginVue = _interopRequireDefault(require("@vitejs/plugin-vue"));
11
11
  var _pluginVueJsx = _interopRequireDefault(require("@vitejs/plugin-vue-jsx"));
12
12
  var _pluginJson = _interopRequireDefault(require("@rollup/plugin-json"));
13
13
  var _vitePluginLibInjectCss = require("vite-plugin-lib-inject-css");
14
+ var _viteTsconfigPaths = _interopRequireDefault(require("vite-tsconfig-paths"));
14
15
  var _vitePluginDts = _interopRequireDefault(require("vite-plugin-dts"));
15
- var _constants = require("../../constants/index.cjs");
16
+ var _fs = require("fs");
16
17
  var _util = require("../../util/index.cjs");
18
+ var _constants = require("../../constants/index.cjs");
17
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
18
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -21,6 +23,14 @@ function definePkgDevViteConfig(opts = {}) {
21
23
  const cwd = process.cwd();
22
24
  const outDir = _path.default.resolve(cwd, "es");
23
25
  rf.sync(outDir);
26
+ let pkgDependencies = [];
27
+ try {
28
+ const pkgJsonPath = _path.default.resolve(cwd, "package.json");
29
+ const pkgJson = JSON.parse((0, _fs.readFileSync)(pkgJsonPath, "utf-8"));
30
+ pkgDependencies = Object.keys(pkgJson.dependencies || {});
31
+ } catch (error) {
32
+ console.warn("Failed to read package.json dependencies:", error);
33
+ }
24
34
  return (0, _util.mergeConfig)((0, _vite.defineConfig)({
25
35
  css: {
26
36
  preprocessorOptions: {
@@ -34,7 +44,18 @@ function definePkgDevViteConfig(opts = {}) {
34
44
  target: "esnext",
35
45
  minify: false,
36
46
  rollupOptions: {
37
- external: _constants.DEFAULT_EXTERNAL,
47
+ external: id => {
48
+ if (pkgDependencies.some(dep => id === dep || id.startsWith(dep + "/"))) {
49
+ return true;
50
+ }
51
+ if (_util.IS_NODE_MODULE.test(id)) {
52
+ return true;
53
+ }
54
+ if (_constants.DEFAULT_EXTERNAL.includes(id)) {
55
+ return true;
56
+ }
57
+ return false;
58
+ },
38
59
  output: {
39
60
  preserveModules: true,
40
61
  entryFileNames: ({
@@ -49,7 +70,7 @@ function definePkgDevViteConfig(opts = {}) {
49
70
  formats: ["es"]
50
71
  }
51
72
  },
52
- plugins: [(0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)(), (0, _vitePluginLibInjectCss.libInjectCss)(), (0, _vitePluginDts.default)({
73
+ plugins: [(0, _viteTsconfigPaths.default)(), (0, _pluginJson.default)(), (0, _pluginVue.default)(), (0, _pluginVueJsx.default)(), (0, _vitePluginLibInjectCss.libInjectCss)(), (0, _vitePluginDts.default)({
53
74
  outDir: [outDir],
54
75
  // 排除测试目录,以及测试文件
55
76
  exclude: ["**/test/**", "**/*.test.ts", "**/*.test.tsx", "**/*.spec.ts", "**/*.spec.tsx"]
@@ -10,3 +10,7 @@ export declare const PROD_MODE = "production";
10
10
  * 默认需要忽略编译的外部依赖
11
11
  */
12
12
  export declare const DEFAULT_EXTERNAL: string[];
13
+ /**
14
+ * 默认忽略编译的依赖列表,用于 pkg 包开发编译时
15
+ */
16
+ export declare const DEFAULT_IGNORED_DEPENDENCIES: string[];
@@ -30,3 +30,4 @@ export const DEFAULT_EXTERNAL = [
30
30
  "@gct-paas/pad",
31
31
  "systemjs"
32
32
  ];
33
+ export const DEFAULT_IGNORED_DEPENDENCIES = ["path-browserify", "qx-util"];
@@ -2,6 +2,7 @@ import { defineConfig } from "vite";
2
2
  import vue from "@vitejs/plugin-vue";
3
3
  import vueJsx from "@vitejs/plugin-vue-jsx";
4
4
  import json from "@rollup/plugin-json";
5
+ import tsconfigPaths from "vite-tsconfig-paths";
5
6
  import path from "path";
6
7
  import { DEFAULT_EXTERNAL } from "../../constants/index.mjs";
7
8
  import { mergeConfig } from "../../util/index.mjs";
@@ -24,6 +25,7 @@ export function defineViteBaseConfig(opts = {}) {
24
25
  }
25
26
  },
26
27
  plugins: [
28
+ tsconfigPaths(),
27
29
  json(),
28
30
  vue(),
29
31
  vueJsx()
@@ -5,13 +5,23 @@ import vue from "@vitejs/plugin-vue";
5
5
  import vueJsx from "@vitejs/plugin-vue-jsx";
6
6
  import json from "@rollup/plugin-json";
7
7
  import { libInjectCss } from "vite-plugin-lib-inject-css";
8
+ import tsconfigPaths from "vite-tsconfig-paths";
8
9
  import dts from "vite-plugin-dts";
10
+ import { readFileSync } from "fs";
11
+ import { mergeConfig, IS_NODE_MODULE } from "../../util/index.mjs";
9
12
  import { DEFAULT_EXTERNAL } from "../../constants/index.mjs";
10
- import { mergeConfig } from "../../util/index.mjs";
11
13
  export function definePkgDevViteConfig(opts = {}) {
12
14
  const cwd = process.cwd();
13
15
  const outDir = path.resolve(cwd, "es");
14
16
  rf.sync(outDir);
17
+ let pkgDependencies = [];
18
+ try {
19
+ const pkgJsonPath = path.resolve(cwd, "package.json");
20
+ const pkgJson = JSON.parse(readFileSync(pkgJsonPath, "utf-8"));
21
+ pkgDependencies = Object.keys(pkgJson.dependencies || {});
22
+ } catch (error) {
23
+ console.warn("Failed to read package.json dependencies:", error);
24
+ }
15
25
  return mergeConfig(
16
26
  defineConfig({
17
27
  css: {
@@ -26,7 +36,20 @@ export function definePkgDevViteConfig(opts = {}) {
26
36
  target: "esnext",
27
37
  minify: false,
28
38
  rollupOptions: {
29
- external: DEFAULT_EXTERNAL,
39
+ external: (id) => {
40
+ if (pkgDependencies.some(
41
+ (dep) => id === dep || id.startsWith(dep + "/")
42
+ )) {
43
+ return true;
44
+ }
45
+ if (IS_NODE_MODULE.test(id)) {
46
+ return true;
47
+ }
48
+ if (DEFAULT_EXTERNAL.includes(id)) {
49
+ return true;
50
+ }
51
+ return false;
52
+ },
30
53
  output: {
31
54
  preserveModules: true,
32
55
  entryFileNames: ({ name }) => `${name}.mjs`,
@@ -40,6 +63,7 @@ export function definePkgDevViteConfig(opts = {}) {
40
63
  }
41
64
  },
42
65
  plugins: [
66
+ tsconfigPaths(),
43
67
  json(),
44
68
  vue(),
45
69
  vueJsx(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gct-paas/build",
3
- "version": "0.1.5-dev.2",
3
+ "version": "0.1.5-dev.3",
4
4
  "type": "module",
5
5
  "description": "paas 平台核心包",
6
6
  "main": "dist/index.cjs",
@@ -91,6 +91,7 @@
91
91
  "vite": "^7.3.1",
92
92
  "vite-plugin-dts": "^4.5.4",
93
93
  "vite-plugin-lib-inject-css": "^2.2.2",
94
+ "vite-tsconfig-paths": "^6.0.5",
94
95
  "vue-eslint-parser": "^10.2.0",
95
96
  "vue-tsc": "^3.2.4"
96
97
  },
@@ -106,5 +107,5 @@
106
107
  "typescript": "^5.9.3",
107
108
  "unbuild": "^3.6.1"
108
109
  },
109
- "gitHead": "d5c70cf34961e0bd1736b97f04b4afdf06386d23"
110
+ "gitHead": "694dd0de8927d3cb6ae87d3b8b4ce0902e878ddc"
110
111
  }