miaoda-react-devkit 0.1.1-beta.21 → 0.1.1-beta.22
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.
- package/cloud/vite.config.js +2 -27
- package/dist/index.cjs +0 -738
- package/dist/index.d.cts +1 -393
- package/dist/index.d.ts +1 -393
- package/dist/index.js +0 -703
- package/dist/vite/index.cjs +5 -28
- package/dist/vite/index.d.cts +1 -10
- package/dist/vite/index.d.ts +1 -10
- package/dist/vite/index.js +11 -33
- package/package.json +1 -1
- package/dist/stubs/sentry-react-stub.js +0 -725
package/dist/vite/index.cjs
CHANGED
|
@@ -32,8 +32,7 @@ var vite_exports = {};
|
|
|
32
32
|
__export(vite_exports, {
|
|
33
33
|
extractRouterPlugin: () => extractRouterPlugin,
|
|
34
34
|
hmrTogglePlugin: () => hmrTogglePlugin,
|
|
35
|
-
withSentryBuild: () => withSentryBuild
|
|
36
|
-
withSentryStub: () => withSentryStub
|
|
35
|
+
withSentryBuild: () => withSentryBuild
|
|
37
36
|
});
|
|
38
37
|
module.exports = __toCommonJS(vite_exports);
|
|
39
38
|
|
|
@@ -41,40 +40,19 @@ module.exports = __toCommonJS(vite_exports);
|
|
|
41
40
|
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;
|
|
42
41
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
43
42
|
|
|
44
|
-
// src/vite/
|
|
43
|
+
// src/vite/withSentryBuild.ts
|
|
45
44
|
var import_node_path = __toESM(require("path"), 1);
|
|
46
45
|
var import_node_url = require("url");
|
|
47
46
|
var SENTRY_MODULE = "@sentry/react";
|
|
48
47
|
var _dirname = import_node_path.default.dirname((0, import_node_url.fileURLToPath)(importMetaUrl));
|
|
49
|
-
var STUB_PATH = import_node_path.default.resolve(_dirname, "../stubs/sentry-react-stub.js");
|
|
50
|
-
function withSentryStub() {
|
|
51
|
-
return {
|
|
52
|
-
name: "miaoda-devkit:sentry-stub",
|
|
53
|
-
enforce: "pre",
|
|
54
|
-
apply: "serve",
|
|
55
|
-
resolveId(id, importer) {
|
|
56
|
-
if (importer && importer.includes("sentry-react-stub")) return null;
|
|
57
|
-
if (id === SENTRY_MODULE) {
|
|
58
|
-
return STUB_PATH;
|
|
59
|
-
}
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// src/vite/withSentryBuild.ts
|
|
66
|
-
var import_node_path2 = __toESM(require("path"), 1);
|
|
67
|
-
var import_node_url2 = require("url");
|
|
68
|
-
var SENTRY_MODULE2 = "@sentry/react";
|
|
69
|
-
var _dirname2 = import_node_path2.default.dirname((0, import_node_url2.fileURLToPath)(importMetaUrl));
|
|
70
|
-
var STUB_PATH2 = import_node_path2.default.resolve(_dirname2, "../stubs/sentry-react-noop-stub.js");
|
|
48
|
+
var STUB_PATH = import_node_path.default.resolve(_dirname, "../stubs/sentry-react-noop-stub.js");
|
|
71
49
|
function withSentryBuild() {
|
|
72
50
|
return {
|
|
73
51
|
name: "miaoda-devkit:sentry-build",
|
|
74
52
|
enforce: "pre",
|
|
75
53
|
apply: "build",
|
|
76
54
|
resolveId(id) {
|
|
77
|
-
if (id ===
|
|
55
|
+
if (id === SENTRY_MODULE) return STUB_PATH;
|
|
78
56
|
return null;
|
|
79
57
|
}
|
|
80
58
|
};
|
|
@@ -972,6 +950,5 @@ var extractRouterPlugin = () => {
|
|
|
972
950
|
0 && (module.exports = {
|
|
973
951
|
extractRouterPlugin,
|
|
974
952
|
hmrTogglePlugin,
|
|
975
|
-
withSentryBuild
|
|
976
|
-
withSentryStub
|
|
953
|
+
withSentryBuild
|
|
977
954
|
});
|
package/dist/vite/index.d.cts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Vite 插件:在 `vite dev` 期间将 @sentry/react 重定向到 stub。
|
|
5
|
-
*
|
|
6
|
-
* - apply: 'serve' → 仅在开发服务器模式下生效
|
|
7
|
-
* - 生产构建时 @sentry/react 正常解析,使用真实 DSN 上报
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
declare function withSentryStub(): Plugin;
|
|
11
|
-
|
|
12
3
|
/**
|
|
13
4
|
* 生产构建使用的 Sentry 替换插件。
|
|
14
5
|
*
|
|
@@ -64,4 +55,4 @@ declare function hmrTogglePlugin(): Plugin;
|
|
|
64
55
|
*/
|
|
65
56
|
declare const extractRouterPlugin: () => Plugin;
|
|
66
57
|
|
|
67
|
-
export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild
|
|
58
|
+
export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild };
|
package/dist/vite/index.d.ts
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { Plugin } from 'vite';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Vite 插件:在 `vite dev` 期间将 @sentry/react 重定向到 stub。
|
|
5
|
-
*
|
|
6
|
-
* - apply: 'serve' → 仅在开发服务器模式下生效
|
|
7
|
-
* - 生产构建时 @sentry/react 正常解析,使用真实 DSN 上报
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
declare function withSentryStub(): Plugin;
|
|
11
|
-
|
|
12
3
|
/**
|
|
13
4
|
* 生产构建使用的 Sentry 替换插件。
|
|
14
5
|
*
|
|
@@ -64,4 +55,4 @@ declare function hmrTogglePlugin(): Plugin;
|
|
|
64
55
|
*/
|
|
65
56
|
declare const extractRouterPlugin: () => Plugin;
|
|
66
57
|
|
|
67
|
-
export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild
|
|
58
|
+
export { extractRouterPlugin, hmrTogglePlugin, withSentryBuild };
|
package/dist/vite/index.js
CHANGED
|
@@ -1,37 +1,16 @@
|
|
|
1
|
-
// src/vite/
|
|
1
|
+
// src/vite/withSentryBuild.ts
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { fileURLToPath } from "url";
|
|
4
4
|
var SENTRY_MODULE = "@sentry/react";
|
|
5
5
|
var _dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
6
|
-
var STUB_PATH = path.resolve(_dirname, "../stubs/sentry-react-stub.js");
|
|
7
|
-
function withSentryStub() {
|
|
8
|
-
return {
|
|
9
|
-
name: "miaoda-devkit:sentry-stub",
|
|
10
|
-
enforce: "pre",
|
|
11
|
-
apply: "serve",
|
|
12
|
-
resolveId(id, importer) {
|
|
13
|
-
if (importer && importer.includes("sentry-react-stub")) return null;
|
|
14
|
-
if (id === SENTRY_MODULE) {
|
|
15
|
-
return STUB_PATH;
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// src/vite/withSentryBuild.ts
|
|
23
|
-
import path2 from "path";
|
|
24
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
25
|
-
var SENTRY_MODULE2 = "@sentry/react";
|
|
26
|
-
var _dirname2 = path2.dirname(fileURLToPath2(import.meta.url));
|
|
27
|
-
var STUB_PATH2 = path2.resolve(_dirname2, "../stubs/sentry-react-noop-stub.js");
|
|
6
|
+
var STUB_PATH = path.resolve(_dirname, "../stubs/sentry-react-noop-stub.js");
|
|
28
7
|
function withSentryBuild() {
|
|
29
8
|
return {
|
|
30
9
|
name: "miaoda-devkit:sentry-build",
|
|
31
10
|
enforce: "pre",
|
|
32
11
|
apply: "build",
|
|
33
12
|
resolveId(id) {
|
|
34
|
-
if (id ===
|
|
13
|
+
if (id === SENTRY_MODULE) return STUB_PATH;
|
|
35
14
|
return null;
|
|
36
15
|
}
|
|
37
16
|
};
|
|
@@ -114,7 +93,7 @@ function hmrTogglePlugin() {
|
|
|
114
93
|
}
|
|
115
94
|
|
|
116
95
|
// src/vite/extractRouterPlugin/index.ts
|
|
117
|
-
import
|
|
96
|
+
import path4 from "path";
|
|
118
97
|
|
|
119
98
|
// src/vite/extractRouterPlugin/babelHelpers.ts
|
|
120
99
|
import _traverse from "@babel/traverse";
|
|
@@ -233,11 +212,11 @@ var flattenRouteTree = (routes) => {
|
|
|
233
212
|
// src/vite/extractRouterPlugin/valueResolver.ts
|
|
234
213
|
import * as t3 from "@babel/types";
|
|
235
214
|
import fs2 from "fs";
|
|
236
|
-
import
|
|
215
|
+
import path3 from "path";
|
|
237
216
|
|
|
238
217
|
// src/vite/extractRouterPlugin/pathUtils.ts
|
|
239
218
|
import fs from "fs";
|
|
240
|
-
import
|
|
219
|
+
import path2 from "path";
|
|
241
220
|
var joinPaths = (...paths) => {
|
|
242
221
|
const parts = paths.filter(Boolean);
|
|
243
222
|
const leadingSlash = parts.length > 0 && parts[0].startsWith("/");
|
|
@@ -258,7 +237,7 @@ var resolveFilePath = async (filepath, extensions = [".ts", ".tsx", ".js", ".jsx
|
|
|
258
237
|
if (await fileExists(`${filepath}${ext}`)) return `${filepath}${ext}`;
|
|
259
238
|
}
|
|
260
239
|
for (const ext of extensions) {
|
|
261
|
-
const indexPath =
|
|
240
|
+
const indexPath = path2.join(filepath, `index${ext}`);
|
|
262
241
|
if (await fileExists(indexPath)) return indexPath;
|
|
263
242
|
}
|
|
264
243
|
return null;
|
|
@@ -379,7 +358,7 @@ var resolveFromFile = async (filePath, exportName, option, context, parentPath,
|
|
|
379
358
|
if (exportName) {
|
|
380
359
|
for (const src of exportAllSources) {
|
|
381
360
|
const srcPath = resolveAlias(src, option.aliasMap);
|
|
382
|
-
const srcAbsolute =
|
|
361
|
+
const srcAbsolute = path3.resolve(path3.dirname(filePath), srcPath);
|
|
383
362
|
const srcResolved = await resolveFilePath(srcAbsolute);
|
|
384
363
|
if (!srcResolved) continue;
|
|
385
364
|
const value = await resolveFromFile(srcResolved, exportName, option, context, parentPath, depth + 1);
|
|
@@ -392,7 +371,7 @@ var resolveModuleBinding = async (binding, currentFilePath, option, context, par
|
|
|
392
371
|
const importDeclaration = binding.path.parent;
|
|
393
372
|
if (!t3.isImportDeclaration(importDeclaration)) return null;
|
|
394
373
|
const importPath = resolveAlias(importDeclaration.source.value, option.aliasMap);
|
|
395
|
-
const absolutePath =
|
|
374
|
+
const absolutePath = path3.resolve(path3.dirname(currentFilePath), importPath);
|
|
396
375
|
const resolvedPath = await resolveFilePath(absolutePath);
|
|
397
376
|
if (!resolvedPath) return null;
|
|
398
377
|
let exportName = null;
|
|
@@ -861,7 +840,7 @@ var extractRouterPlugin = () => {
|
|
|
861
840
|
return acc;
|
|
862
841
|
}, {});
|
|
863
842
|
projectRoot = config.root || process.cwd();
|
|
864
|
-
appPath = await resolveFilePath(
|
|
843
|
+
appPath = await resolveFilePath(path4.resolve(projectRoot, "src/App"), [".tsx", ".jsx"]) ?? "";
|
|
865
844
|
},
|
|
866
845
|
/** 构建开始时清空所有缓存 */
|
|
867
846
|
buildStart() {
|
|
@@ -928,6 +907,5 @@ var extractRouterPlugin = () => {
|
|
|
928
907
|
export {
|
|
929
908
|
extractRouterPlugin,
|
|
930
909
|
hmrTogglePlugin,
|
|
931
|
-
withSentryBuild
|
|
932
|
-
withSentryStub
|
|
910
|
+
withSentryBuild
|
|
933
911
|
};
|