@_tc/template-core 0.0.1-bate.38 → 0.0.1-bate.39

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.
@@ -10,14 +10,20 @@ glob = require_runtime.__toESM(glob);
10
10
  let fs = require("fs");
11
11
  let _tailwindcss_vite = require("@tailwindcss/vite");
12
12
  _tailwindcss_vite = require_runtime.__toESM(_tailwindcss_vite);
13
+ let module$1 = require("module");
14
+ let url = require("url");
13
15
  let vite = require("vite");
14
16
  //#region bundler/utils.ts
17
+ var currentFile = typeof __filename === "string" ? __filename : (0, url.fileURLToPath)({}.url);
18
+ var currentDir = path.default.dirname(currentFile);
15
19
  var base = process.cwd();
16
- var framePath = path.default.resolve(__dirname, "../../");
17
- var frameNodePath = path.default.resolve(__dirname, "../");
20
+ var requireFromFrame = (0, module$1.createRequire)(currentFile);
21
+ var framePath = path.default.resolve(currentDir, "../../");
22
+ var frameNodePath = path.default.resolve(currentDir, "../");
18
23
  var frameFEPath = path.default.resolve(framePath, "./fe/frontend");
19
24
  var runPath = path.default.resolve(base, ".");
20
25
  var runFEPath = path.default.resolve(runPath, "./frontend");
26
+ var resolvePackageDir = (packageName) => path.default.dirname(requireFromFrame.resolve(`${packageName}/package.json`));
21
27
  /**
22
28
  *
23
29
  * 寻找 frontend\/**\/*.entry.[j|t]s(x)?
@@ -145,7 +151,7 @@ function resolveAliasWithFallback(aliasList) {
145
151
  ];
146
152
  return aliasList.reduce((o, [aliasName, aliasPath]) => {
147
153
  const businessFilePath = aliasExtensions.map((ext) => path.default.resolve(runFEPath, aliasPath + ext)).find((filePath) => (0, fs.existsSync)(filePath));
148
- let filePath = path.default.resolve(__dirname, "./defaultAlias");
154
+ let filePath = path.default.resolve(currentDir, "./defaultAlias");
149
155
  if (businessFilePath) filePath = businessFilePath;
150
156
  o[aliasName] = filePath;
151
157
  return o;
@@ -168,7 +174,9 @@ var VBuildFE = async (input, OperatingEnv) => {
168
174
  rollupOptions: { input }
169
175
  },
170
176
  resolve: { alias: {
171
- "@tc/ui-react": path.default.resolve(__dirname, "../../fe/packages/ui/react/"),
177
+ "@tc/ui-react": path.default.resolve(currentDir, "../../fe/packages/ui/react/"),
178
+ react: resolvePackageDir("react"),
179
+ "react-dom": resolvePackageDir("react-dom"),
172
180
  ...resolveAliasWithFallback([["$business/SchemaForm/data", "./extended/SchemaForm/data"]])
173
181
  } }
174
182
  });
@@ -5,14 +5,20 @@ import path from "path";
5
5
  import * as glob from "glob";
6
6
  import { copyFileSync, existsSync, readFileSync, readdirSync, rmdirSync, unlinkSync, writeFileSync } from "fs";
7
7
  import tailwindcss from "@tailwindcss/vite";
8
+ import { createRequire } from "module";
9
+ import { fileURLToPath } from "url";
8
10
  import { build } from "vite";
9
11
  //#region bundler/utils.ts
12
+ var currentFile = typeof __filename === "string" ? __filename : fileURLToPath(import.meta.url);
13
+ var currentDir = path.dirname(currentFile);
10
14
  var base = process.cwd();
11
- var framePath = path.resolve(__dirname, "../../");
12
- var frameNodePath = path.resolve(__dirname, "../");
15
+ var requireFromFrame = createRequire(currentFile);
16
+ var framePath = path.resolve(currentDir, "../../");
17
+ var frameNodePath = path.resolve(currentDir, "../");
13
18
  var frameFEPath = path.resolve(framePath, "./fe/frontend");
14
19
  var runPath = path.resolve(base, ".");
15
20
  var runFEPath = path.resolve(runPath, "./frontend");
21
+ var resolvePackageDir = (packageName) => path.dirname(requireFromFrame.resolve(`${packageName}/package.json`));
16
22
  /**
17
23
  *
18
24
  * 寻找 frontend\/**\/*.entry.[j|t]s(x)?
@@ -140,7 +146,7 @@ function resolveAliasWithFallback(aliasList) {
140
146
  ];
141
147
  return aliasList.reduce((o, [aliasName, aliasPath]) => {
142
148
  const businessFilePath = aliasExtensions.map((ext) => path.resolve(runFEPath, aliasPath + ext)).find((filePath) => existsSync(filePath));
143
- let filePath = path.resolve(__dirname, "./defaultAlias");
149
+ let filePath = path.resolve(currentDir, "./defaultAlias");
144
150
  if (businessFilePath) filePath = businessFilePath;
145
151
  o[aliasName] = filePath;
146
152
  return o;
@@ -163,7 +169,9 @@ var VBuildFE = async (input, OperatingEnv) => {
163
169
  rollupOptions: { input }
164
170
  },
165
171
  resolve: { alias: {
166
- "@tc/ui-react": path.resolve(__dirname, "../../fe/packages/ui/react/"),
172
+ "@tc/ui-react": path.resolve(currentDir, "../../fe/packages/ui/react/"),
173
+ react: resolvePackageDir("react"),
174
+ "react-dom": resolvePackageDir("react-dom"),
167
175
  ...resolveAliasWithFallback([["$business/SchemaForm/data", "./extended/SchemaForm/data"]])
168
176
  } }
169
177
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@_tc/template-core",
3
- "version": "0.0.1-bate.38",
3
+ "version": "0.0.1-bate.39",
4
4
  "description": "A TypeScript Koa framework template - Monorepo root",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",