@vue3-oop/preset-vue 2.4.14

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.
@@ -0,0 +1,67 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
25
+ mod2
26
+ ));
27
+ var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
28
+
29
+ // src/requireHook.ts
30
+ var requireHook_exports = {};
31
+ __export(requireHook_exports, {
32
+ hookPropertyMap: () => hookPropertyMap
33
+ });
34
+ module.exports = __toCommonJS(requireHook_exports);
35
+ var import_deepImports = __toESM(require("@umijs/bundler-webpack/compiled/webpack/deepImports.json"));
36
+ var hookPropertyMap = /* @__PURE__ */ new Map([
37
+ ["webpack", "@umijs/bundler-webpack/compiled/webpack"],
38
+ ["webpack/package", "@umijs/bundler-webpack/compiled/webpack/package"],
39
+ ["webpack/package.json", "@umijs/bundler-webpack/compiled/webpack/package"],
40
+ ["webpack/lib/webpack", "@umijs/bundler-webpack/compiled/webpack"],
41
+ ["webpack/lib/webpack.js", "@umijs/bundler-webpack/compiled/webpack"],
42
+ ["tapable", "@umijs/bundler-utils/compiled/tapable"]
43
+ ]);
44
+ import_deepImports.default.forEach((item) => {
45
+ const name = item.split("/").pop();
46
+ hookPropertyMap.set(item, `@umijs/bundler-webpack/compiled/webpack/${name}`);
47
+ hookPropertyMap.set(
48
+ `${item}.js`,
49
+ `@umijs/bundler-webpack/compiled/webpack/${name}`
50
+ );
51
+ });
52
+ var mod = require("module");
53
+ var resolveFilename = mod._resolveFilename;
54
+ mod._resolveFilename = function(request, parent, isMain, options) {
55
+ const hookResolved = hookPropertyMap.get(request);
56
+ return resolveFilename.call(
57
+ mod,
58
+ hookResolved ?? request,
59
+ parent,
60
+ isMain,
61
+ options
62
+ );
63
+ };
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ hookPropertyMap
67
+ });
@@ -0,0 +1,11 @@
1
+ import type { IApi } from 'dumi';
2
+ export declare const BABEL_STANDALONE_CDN = "https://cdn.bootcdn.net/ajax/libs/babel-standalone/7.22.17/babel.min.js";
3
+ export declare const TYPESCRIPT_STANDALONE_CDN = "https://cdn.bootcdn.net/ajax/libs/typescript/5.5.3/typescript.min.js";
4
+ export declare function getPluginPath(api: IApi, filename: string): string;
5
+ export declare function hasDep(pkg: any, dep: string): any;
6
+ export declare function getPkgPath(dep: string, cwd: string): string;
7
+ export declare function getDepVersion(opts: {
8
+ pkg: any;
9
+ cwd: string;
10
+ dep: string;
11
+ }): string | undefined;
package/dist/shared.js ADDED
@@ -0,0 +1,64 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/shared.ts
20
+ var shared_exports = {};
21
+ __export(shared_exports, {
22
+ BABEL_STANDALONE_CDN: () => BABEL_STANDALONE_CDN,
23
+ TYPESCRIPT_STANDALONE_CDN: () => TYPESCRIPT_STANDALONE_CDN,
24
+ getDepVersion: () => getDepVersion,
25
+ getPkgPath: () => getPkgPath,
26
+ getPluginPath: () => getPluginPath,
27
+ hasDep: () => hasDep
28
+ });
29
+ module.exports = __toCommonJS(shared_exports);
30
+ var import_plugin_utils = require("dumi/plugin-utils");
31
+ var import_path = require("path");
32
+ var BABEL_STANDALONE_CDN = "https://cdn.bootcdn.net/ajax/libs/babel-standalone/7.22.17/babel.min.js";
33
+ var TYPESCRIPT_STANDALONE_CDN = "https://cdn.bootcdn.net/ajax/libs/typescript/5.5.3/typescript.min.js";
34
+ function getPluginPath(api, filename) {
35
+ return (0, import_plugin_utils.winPath)(
36
+ (0, import_path.join)(api.paths.absTmpPath, `plugin-${api.plugin.key}`, filename)
37
+ );
38
+ }
39
+ function hasDep(pkg, dep) {
40
+ var _a, _b;
41
+ return ((_a = pkg.dependencies) == null ? void 0 : _a[dep]) || ((_b = pkg.devDependencies) == null ? void 0 : _b[dep]);
42
+ }
43
+ function getPkgPath(dep, cwd) {
44
+ return (0, import_path.dirname)(
45
+ import_plugin_utils.resolve.sync(`${dep}/package.json`, {
46
+ basedir: cwd
47
+ })
48
+ );
49
+ }
50
+ function getDepVersion(opts) {
51
+ if (hasDep(opts.pkg, opts.dep)) {
52
+ const pkgPath = getPkgPath(opts.dep, opts.cwd);
53
+ return require(pkgPath).version;
54
+ }
55
+ }
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ BABEL_STANDALONE_CDN,
59
+ TYPESCRIPT_STANDALONE_CDN,
60
+ getDepVersion,
61
+ getPkgPath,
62
+ getPluginPath,
63
+ hasDep
64
+ });
@@ -0,0 +1,2 @@
1
+ import type { IApi } from 'dumi';
2
+ export default function checkVersion(api: IApi): void;
@@ -0,0 +1,52 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/vue/checkVersion.ts
20
+ var checkVersion_exports = {};
21
+ __export(checkVersion_exports, {
22
+ default: () => checkVersion
23
+ });
24
+ module.exports = __toCommonJS(checkVersion_exports);
25
+ var import_shared = require("../shared");
26
+ var import_compare_versions = require("compare-versions");
27
+ var import_plugin_utils = require("dumi/plugin-utils");
28
+ function checkVersion(api) {
29
+ const vueVersion = (0, import_shared.getDepVersion)({
30
+ pkg: api.pkg,
31
+ cwd: api.cwd,
32
+ dep: "vue"
33
+ });
34
+ if (!vueVersion) {
35
+ throw new Error("Please install Vue.");
36
+ }
37
+ import_plugin_utils.logger.info(import_plugin_utils.chalk.cyan.bold(`Vue v${vueVersion}`));
38
+ const shouldInstallCompiler = (0, import_compare_versions.compare)(vueVersion, "3.3.6", "<");
39
+ const hasOwnCompiler = (0, import_shared.hasDep)(api.pkg, "@vue/compiler-sfc");
40
+ if (shouldInstallCompiler && !hasOwnCompiler) {
41
+ throw new Error(`Please install @vue/compiler-sfc v${vueVersion}`);
42
+ }
43
+ if (shouldInstallCompiler) {
44
+ api.modifyConfig((memo) => {
45
+ memo.alias = {
46
+ ...memo.alias,
47
+ "vue/compiler-sfc": "@vue/compiler-sfc"
48
+ };
49
+ return memo;
50
+ });
51
+ }
52
+ }
@@ -0,0 +1,3 @@
1
+ import type { IApi } from 'dumi';
2
+ declare const _default: (api: IApi) => void;
3
+ export default _default;
@@ -0,0 +1,56 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/vue/index.ts
30
+ var vue_exports = {};
31
+ __export(vue_exports, {
32
+ default: () => vue_default
33
+ });
34
+ module.exports = __toCommonJS(vue_exports);
35
+ var import_checkVersion = __toESM(require("./checkVersion"));
36
+ var import_techStack = __toESM(require("./techStack"));
37
+ var import_webpack = __toESM(require("./webpack"));
38
+ var vue_default = (api) => {
39
+ api.describe({
40
+ key: "preset-vue"
41
+ // dont add `:`, if use `api.writeTmpFile` in plugin
42
+ });
43
+ (0, import_checkVersion.default)(api);
44
+ (0, import_webpack.default)(api);
45
+ api.modifyDefaultConfig((config) => {
46
+ config.define = {
47
+ ...config.define,
48
+ __VUE_OPTIONS_API__: true,
49
+ __VUE_PROD_DEVTOOLS__: false,
50
+ __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: false
51
+ // vue3.4
52
+ };
53
+ return config;
54
+ });
55
+ (0, import_techStack.default)(api);
56
+ };
@@ -0,0 +1,2 @@
1
+ import type { IApi } from 'dumi';
2
+ export default function registerTechStack(api: IApi): void;
@@ -0,0 +1,95 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/vue/techStack/index.ts
20
+ var techStack_exports = {};
21
+ __export(techStack_exports, {
22
+ default: () => registerTechStack
23
+ });
24
+ module.exports = __toCommonJS(techStack_exports);
25
+ var import_shared = require("../../shared");
26
+ var import_plugin_utils = require("dumi/plugin-utils");
27
+ var import_path = require("path");
28
+ var import_jsx = require("./jsx");
29
+ var import_sfc = require("./sfc");
30
+ var COMPILE_FILENAME = "compiler.mjs";
31
+ var RENDERER_FILENAME = "renderer.mjs";
32
+ var PREFLIGHT_FILENAME = "preflight.mjs";
33
+ function registerTechStack(api) {
34
+ var _a;
35
+ const vueConfig = (_a = api.userConfig) == null ? void 0 : _a.vue;
36
+ const pkgPath = (0, import_shared.getPkgPath)("@dumijs/preset-vue", api.cwd);
37
+ const libPath = (0, import_path.join)(pkgPath, "/lib");
38
+ api.onGenerateFiles(() => {
39
+ api.writeTmpFile({
40
+ path: COMPILE_FILENAME,
41
+ content: import_plugin_utils.fsExtra.readFileSync((0, import_path.join)(libPath, COMPILE_FILENAME), "utf8")
42
+ });
43
+ api.writeTmpFile({
44
+ path: RENDERER_FILENAME,
45
+ content: import_plugin_utils.fsExtra.readFileSync((0, import_path.join)(libPath, RENDERER_FILENAME), "utf8")
46
+ });
47
+ api.writeTmpFile({
48
+ path: PREFLIGHT_FILENAME,
49
+ content: import_plugin_utils.fsExtra.readFileSync((0, import_path.join)(libPath, PREFLIGHT_FILENAME), "utf8")
50
+ });
51
+ });
52
+ const runtimeOpts = {
53
+ compilePath: (0, import_shared.getPluginPath)(api, COMPILE_FILENAME),
54
+ rendererPath: (0, import_shared.getPluginPath)(api, RENDERER_FILENAME),
55
+ preflightPath: (0, import_shared.getPluginPath)(api, PREFLIGHT_FILENAME),
56
+ pluginPath: (0, import_path.join)(libPath, "runtimePlugin.mjs")
57
+ };
58
+ if (vueConfig.supportTsMetadata) {
59
+ globalThis.supportTsMetadata = true;
60
+ }
61
+ api.addHTMLHeadScripts(() => {
62
+ var _a2, _b;
63
+ const scripts = [
64
+ {
65
+ src: ((_a2 = vueConfig == null ? void 0 : vueConfig.compiler) == null ? void 0 : _a2.babelStandaloneCDN) || import_shared.BABEL_STANDALONE_CDN,
66
+ async: true
67
+ }
68
+ ];
69
+ if (vueConfig.supportTsMetadata) {
70
+ scripts.push({
71
+ src: ((_b = vueConfig == null ? void 0 : vueConfig.compiler) == null ? void 0 : _b.typescriptCDN) || import_shared.TYPESCRIPT_STANDALONE_CDN,
72
+ async: true
73
+ });
74
+ }
75
+ return scripts;
76
+ });
77
+ api.modifyConfig((memo) => {
78
+ memo.externals = {
79
+ ...memo.externals,
80
+ "@babel/standalone": "Babel",
81
+ typescript: "ts"
82
+ };
83
+ return memo;
84
+ });
85
+ api.register({
86
+ key: "registerTechStack",
87
+ stage: 0,
88
+ fn: () => (0, import_jsx.VueJSXTechStack)(runtimeOpts)
89
+ });
90
+ api.register({
91
+ key: "registerTechStack",
92
+ stage: 1,
93
+ fn: () => (0, import_sfc.VueSfcTechStack)(runtimeOpts)
94
+ });
95
+ }
@@ -0,0 +1,2 @@
1
+ import type { IDumiTechStackRuntimeOpts } from 'dumi/tech-stack-utils';
2
+ export declare const VueJSXTechStack: (runtimeOpts: IDumiTechStackRuntimeOpts) => import("dumi/tech-stack-utils").IDumiTechStack;
@@ -0,0 +1,81 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/vue/techStack/jsx.ts
30
+ var jsx_exports = {};
31
+ __export(jsx_exports, {
32
+ VueJSXTechStack: () => VueJSXTechStack
33
+ });
34
+ module.exports = __toCommonJS(jsx_exports);
35
+ var import_node = require("../../compiler/node");
36
+ var import_tech_stack_utils = require("dumi/tech-stack-utils");
37
+ var import_hash_sum = __toESM(require("hash-sum"));
38
+ var VueJSXTechStack = (runtimeOpts) => (0, import_tech_stack_utils.defineTechStack)({
39
+ name: "vue3-tsx",
40
+ runtimeOpts,
41
+ isSupported(_, lang) {
42
+ return ["jsx", "tsx"].includes(lang);
43
+ },
44
+ onBlockLoad(args) {
45
+ if (!args.path.endsWith(".tsx") && !args.path.endsWith(".jsx"))
46
+ return null;
47
+ const { filename } = args;
48
+ return {
49
+ type: "tsx",
50
+ content: (0, import_node.compile)({
51
+ id: filename,
52
+ filename,
53
+ code: args.entryPointCode
54
+ })
55
+ };
56
+ },
57
+ transformCode(raw, opts) {
58
+ if (opts.type === "code-block") {
59
+ const filename = opts.fileAbsPath;
60
+ const result = (0, import_node.compile)({
61
+ id: (0, import_hash_sum.default)(raw),
62
+ filename,
63
+ code: raw
64
+ });
65
+ if (result) {
66
+ const code = (0, import_tech_stack_utils.wrapDemoWithFn)(result, {
67
+ filename,
68
+ parserConfig: {
69
+ syntax: "ecmascript"
70
+ }
71
+ });
72
+ return `(${code})()`;
73
+ }
74
+ }
75
+ return raw;
76
+ }
77
+ });
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ VueJSXTechStack
81
+ });
@@ -0,0 +1,2 @@
1
+ import type { IDumiTechStackRuntimeOpts } from 'dumi/tech-stack-utils';
2
+ export declare const VueSfcTechStack: (runtimeOpts: IDumiTechStackRuntimeOpts) => import("dumi/tech-stack-utils").IDumiTechStack;
@@ -0,0 +1,80 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/vue/techStack/sfc.ts
30
+ var sfc_exports = {};
31
+ __export(sfc_exports, {
32
+ VueSfcTechStack: () => VueSfcTechStack
33
+ });
34
+ module.exports = __toCommonJS(sfc_exports);
35
+ var import_node = require("../../compiler/node");
36
+ var import_plugin_utils = require("dumi/plugin-utils");
37
+ var import_tech_stack_utils = require("dumi/tech-stack-utils");
38
+ var import_hash_sum = __toESM(require("hash-sum"));
39
+ var VueSfcTechStack = (runtimeOpts) => (0, import_tech_stack_utils.defineTechStack)({
40
+ name: "vue3-sfc",
41
+ runtimeOpts,
42
+ isSupported(_, lang) {
43
+ return ["vue"].includes(lang);
44
+ },
45
+ onBlockLoad(args) {
46
+ if (!args.path.endsWith(".vue")) return null;
47
+ const result = import_node.compiler.compileSFC({
48
+ id: args.path,
49
+ code: args.entryPointCode,
50
+ filename: args.filename
51
+ });
52
+ return {
53
+ type: "tsx",
54
+ content: Array.isArray(result) ? "" : result.js
55
+ };
56
+ },
57
+ transformCode(raw, opts) {
58
+ if (opts.type === "code-block") {
59
+ const filename = opts.fileAbsPath;
60
+ const id = (0, import_hash_sum.default)(raw);
61
+ const js = (0, import_node.compile)({ id, filename, code: raw });
62
+ if (Array.isArray(js)) {
63
+ import_plugin_utils.logger.error(js);
64
+ return "";
65
+ }
66
+ const code = (0, import_tech_stack_utils.wrapDemoWithFn)(js, {
67
+ filename,
68
+ parserConfig: {
69
+ syntax: "ecmascript"
70
+ }
71
+ });
72
+ return `(${code})()`;
73
+ }
74
+ return raw;
75
+ }
76
+ });
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ VueSfcTechStack
80
+ });
@@ -0,0 +1,3 @@
1
+ import type Config from '@umijs/bundler-webpack/compiled/webpack-5-chain';
2
+ import type { IApi } from 'dumi';
3
+ export declare function getConfig(config: Config, api: IApi): void;
@@ -0,0 +1,85 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+
29
+ // src/vue/webpack/config.ts
30
+ var config_exports = {};
31
+ __export(config_exports, {
32
+ getConfig: () => getConfig
33
+ });
34
+ module.exports = __toCommonJS(config_exports);
35
+ var import_tech_stack_utils = require("dumi/tech-stack-utils");
36
+ var import_node_path = __toESM(require("node:path"));
37
+ var import_pluginWebpack5 = __toESM(require("vue-loader/dist/pluginWebpack5.js"));
38
+ function getConfig(config, api) {
39
+ var _a;
40
+ const dumiSrc = import_node_path.default.resolve(api.paths.absSrcPath);
41
+ const babelInUmi = config.module.rule("src").use("babel-loader").entries();
42
+ const { userConfig } = api;
43
+ config.module.rule("jsx-ts-tsx").include.add(dumiSrc).end();
44
+ config.module.rule("vue-jsx-tsx").test(/\.(jsx|ts|tsx)$/).exclude.add(dumiSrc).end().use("babel-loader").loader(babelInUmi.loader).options({
45
+ ...babelInUmi.options,
46
+ presets: [...babelInUmi.options.presets, (0, import_tech_stack_utils.babelPresetTypeScript)()],
47
+ plugins: [require.resolve("../../../compiled/@vue/babel-plugin-jsx")]
48
+ });
49
+ if ((_a = userConfig.vue) == null ? void 0 : _a.supportTsMetadata) {
50
+ config.module.rule("vue-jsx-tsx").use("ts-loader").loader(require.resolve("ts-loader")).after("babel-loader").options({
51
+ transpileOnly: true,
52
+ configFile: userConfig.vue.tsconfigPath
53
+ });
54
+ }
55
+ config.module.noParse(/^(vue|vue-router|vuex|vuex-router-sync)$/);
56
+ config.module.rule("esm").type("javascript/auto").test(/\.m?jsx?$/).resolve.set("fullySpecified", false);
57
+ config.resolve.extensions.merge([".vue"]).end();
58
+ config.module.rule("vue").test(/\.vue$/).exclude.add(dumiSrc).end().use("vue-loader").loader(require.resolve("vue-loader")).options({
59
+ babelParserPlugins: ["jsx", "classProperties", "decorators-legacy"]
60
+ });
61
+ config.plugin("vue-loader-plugin").use(import_pluginWebpack5.default);
62
+ config.module.rule("vue-style").test(/\.vue$/).exclude.add(dumiSrc).end().resourceQuery(/type=style/).sideEffects(true);
63
+ config.module.rule("fix-element-ui-plus").test(/\.mjs$/).include.add(/node_modules/).end().type("javascript/auto").resolve.fullySpecified(false);
64
+ config.module.rules.delete("asset");
65
+ const inlineLimit = parseInt(userConfig.inlineLimit || "10000", 10);
66
+ config.module.rule("avif").test(/\.avif$/).type("asset").mimetype("image/avif").parser({
67
+ dataUrlCondition: {
68
+ maxSize: inlineLimit
69
+ }
70
+ });
71
+ config.module.rule("image").test(/\.(bmp|gif|jpg|jpeg|png)$/).type("asset").parser({
72
+ dataUrlCondition: {
73
+ maxSize: inlineLimit
74
+ }
75
+ });
76
+ config.module.rules.delete("svg");
77
+ config.module.rule("svg").test(/\.svg$/).use("url-loader").loader(require.resolve("@umijs/bundler-webpack/compiled/url-loader")).options({
78
+ limit: userConfig.inlineLimit,
79
+ fallback: require.resolve("@umijs/bundler-webpack/compiled/file-loader")
80
+ }).end();
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ getConfig
85
+ });
@@ -0,0 +1,2 @@
1
+ import type { IApi } from 'dumi';
2
+ export default function (api: IApi): void;