@l-comedy/core 0.1.3 → 0.1.4
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/dist/index.d.ts +8 -3
- package/dist/plugins/app-config/createLComedyPluginAppConfig.d.ts +1 -1
- package/dist/plugins/app-config/createLComedyPluginAppConfig.js +5 -2
- package/dist/plugins/app-config/index.d.ts +1 -1
- package/dist/plugins/app-config/index.js +5 -2
- package/dist/plugins/global-css/createLComedyPluginGlobalCSS.d.ts +1 -1
- package/dist/plugins/global-css/index.d.ts +1 -1
- package/dist/plugins/html/createHtmlFile.d.ts +1 -1
- package/dist/plugins/html/createLComedyPluginHtml.d.ts +1 -1
- package/dist/plugins/html/createTemplateParameters.d.ts +1 -1
- package/dist/plugins/html/index.d.ts +1 -1
- package/dist/plugins/layout/createLComedyPluginLayout.d.ts +1 -1
- package/dist/plugins/layout/index.d.ts +1 -1
- package/dist/plugins/page-loading/createLComedyPluginPageLoading.d.ts +1 -1
- package/dist/plugins/page-loading/index.d.ts +1 -1
- package/dist/plugins/redux-toolkit/createLComedyPluginReduxToolkit.d.ts +9 -0
- package/dist/plugins/redux-toolkit/createLComedyPluginReduxToolkit.js +152 -0
- package/dist/plugins/redux-toolkit/index.d.ts +6 -0
- package/dist/plugins/redux-toolkit/index.js +150 -0
- package/dist/plugins/route/createLComedyPluginRoute.d.ts +1 -1
- package/dist/plugins/route/index.d.ts +1 -1
- package/dist/plugins/{types.d-LN_39F7o.d.ts → types.d-CDy64Uxi.d.ts} +8 -3
- package/dist/run.js +16 -3
- package/package.json +4 -1
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,11 @@ interface UserConfig {
|
|
|
16
16
|
basename?: string
|
|
17
17
|
routes?: RouteConfig[]
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
reduxToolkit?: {
|
|
20
|
+
/** 相对于@ */
|
|
21
|
+
slicesDir?: string
|
|
22
|
+
}
|
|
23
|
+
plugins?: Array<'route' | 'redux-toolkit' | LComedyPlugin>
|
|
20
24
|
rspackConfig?: Configuration
|
|
21
25
|
sourceDir?: string
|
|
22
26
|
output?: string
|
|
@@ -29,11 +33,11 @@ interface LComedyPlugin {
|
|
|
29
33
|
name: string
|
|
30
34
|
generateFiles?: (setupConfig: SetupConfigPlugin) => Promise<void> | viod
|
|
31
35
|
modifyEntry?: (
|
|
32
|
-
setupConfig: SetupConfigPlugin
|
|
36
|
+
setupConfig: SetupConfigPlugin,
|
|
33
37
|
) => EntryModifier | Promise<EntryModifier>
|
|
34
38
|
rspackConfig?: (
|
|
35
39
|
rspackConfig: Configuration,
|
|
36
|
-
setupConfig: SetupConfig
|
|
40
|
+
setupConfig: SetupConfig,
|
|
37
41
|
) => Configuration | Promise<Configuration>
|
|
38
42
|
runtimeExports?: string[]
|
|
39
43
|
}
|
|
@@ -72,6 +76,7 @@ type SetupConfigPlugin = Omit<SetupConfig, 'plugins'>
|
|
|
72
76
|
|
|
73
77
|
interface EntryModifier {
|
|
74
78
|
imports?: string[]
|
|
79
|
+
runtimeExports?: string[]
|
|
75
80
|
reactImports?: string[]
|
|
76
81
|
beforeRender?: string
|
|
77
82
|
afterRender?: string
|
|
@@ -82,7 +82,9 @@ function createLComedyPluginAppConfig() {
|
|
|
82
82
|
transpileOnly: true,
|
|
83
83
|
compilerOptions: {
|
|
84
84
|
paths: {
|
|
85
|
-
|
|
85
|
+
// TODO: 使用变量
|
|
86
|
+
"@/*": ["src/*"],
|
|
87
|
+
"@@/*": [".comedy/*"]
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
}
|
|
@@ -133,7 +135,8 @@ function createLComedyPluginAppConfig() {
|
|
|
133
135
|
patterns: [
|
|
134
136
|
{
|
|
135
137
|
from: publicDir,
|
|
136
|
-
to: "."
|
|
138
|
+
to: ".",
|
|
139
|
+
noErrorOnMissing: true
|
|
137
140
|
}
|
|
138
141
|
]
|
|
139
142
|
})
|
|
@@ -84,7 +84,9 @@ function createLComedyPluginAppConfig() {
|
|
|
84
84
|
transpileOnly: true,
|
|
85
85
|
compilerOptions: {
|
|
86
86
|
paths: {
|
|
87
|
-
|
|
87
|
+
// TODO: 使用变量
|
|
88
|
+
"@/*": ["src/*"],
|
|
89
|
+
"@@/*": [".comedy/*"]
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
}
|
|
@@ -135,7 +137,8 @@ function createLComedyPluginAppConfig() {
|
|
|
135
137
|
patterns: [
|
|
136
138
|
{
|
|
137
139
|
from: publicDir,
|
|
138
|
-
to: "."
|
|
140
|
+
to: ".",
|
|
141
|
+
noErrorOnMissing: true
|
|
139
142
|
}
|
|
140
143
|
]
|
|
141
144
|
})
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { L as LComedyPlugin } from '../types.d-CDy64Uxi.js';
|
|
2
|
+
import '@rspack/core';
|
|
3
|
+
import 'tsup';
|
|
4
|
+
import 'html-webpack-plugin';
|
|
5
|
+
import '@jest/types';
|
|
6
|
+
|
|
7
|
+
declare function createLComedyPluginReduxToolkit(): LComedyPlugin;
|
|
8
|
+
|
|
9
|
+
export { createLComedyPluginReduxToolkit };
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/plugins/redux-toolkit/createLComedyPluginReduxToolkit.ts
|
|
51
|
+
var createLComedyPluginReduxToolkit_exports = {};
|
|
52
|
+
__export(createLComedyPluginReduxToolkit_exports, {
|
|
53
|
+
createLComedyPluginReduxToolkit: () => createLComedyPluginReduxToolkit
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(createLComedyPluginReduxToolkit_exports);
|
|
56
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
57
|
+
var import_path = __toESM(require("path"));
|
|
58
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
59
|
+
function createLComedyPluginReduxToolkit() {
|
|
60
|
+
return {
|
|
61
|
+
name: "l-comedy-plugin-redux-toolkit",
|
|
62
|
+
generateFiles(setupConfig) {
|
|
63
|
+
return __async(this, null, function* () {
|
|
64
|
+
var _a2;
|
|
65
|
+
const sliceDir = ((_a2 = setupConfig.userConfig.reduxToolkit) == null ? void 0 : _a2.slicesDir) || `store/slice`;
|
|
66
|
+
const entires = yield (0, import_fast_glob.default)([`${sliceDir}/*.ts`, "!**/*.tsx"], {
|
|
67
|
+
cwd: setupConfig.sourcePath,
|
|
68
|
+
onlyFiles: true
|
|
69
|
+
});
|
|
70
|
+
const fileMap = entires.map((filePath) => ({
|
|
71
|
+
name: import_path.default.parse(filePath).name,
|
|
72
|
+
filePath
|
|
73
|
+
}));
|
|
74
|
+
import_fs_extra.default.outputFileSync(
|
|
75
|
+
import_path.default.posix.join(setupConfig.workDir, "runtimes", "redux/store.ts"),
|
|
76
|
+
`import { configureStore } from '@reduxjs/toolkit';
|
|
77
|
+
import {
|
|
78
|
+
useDispatch,
|
|
79
|
+
useSelector,
|
|
80
|
+
useStore,
|
|
81
|
+
} from 'react-redux';
|
|
82
|
+
import type { TypedUseSelectorHook } from 'react-redux';
|
|
83
|
+
|
|
84
|
+
// \u5BFC\u5165\u6240\u6709 slice reducer
|
|
85
|
+
${fileMap.map((item) => `import ${item.name}Reducer from '@/${sliceDir}/${item.name}';`).join("\n")}
|
|
86
|
+
|
|
87
|
+
// \u521B\u5EFA store
|
|
88
|
+
export const store = configureStore({
|
|
89
|
+
reducer: {
|
|
90
|
+
${fileMap.map((item) => `${item.name}: ${item.name}Reducer,`).join("\n")}
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
export type RootState = ReturnType<typeof store.getState>;
|
|
95
|
+
export type AppDispatch = typeof store.dispatch;
|
|
96
|
+
|
|
97
|
+
export const useAppDispatch = () => useDispatch<AppDispatch>();
|
|
98
|
+
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
|
99
|
+
export const useAppStore = () => useStore<RootState>();
|
|
100
|
+
`
|
|
101
|
+
);
|
|
102
|
+
});
|
|
103
|
+
},
|
|
104
|
+
modifyEntry() {
|
|
105
|
+
return __async(this, null, function* () {
|
|
106
|
+
return {
|
|
107
|
+
imports: [
|
|
108
|
+
`import { Provider as ReduxProvider } from 'react-redux'`,
|
|
109
|
+
`import { store as reduxStore } from './runtimes/redux/store'`
|
|
110
|
+
],
|
|
111
|
+
runtimeExports: [
|
|
112
|
+
`export { useAppSelector, useAppDispatch, useAppStore } from './runtimes/redux/store'`
|
|
113
|
+
],
|
|
114
|
+
appWrap(app) {
|
|
115
|
+
return `<ReduxProvider store={reduxStore}>
|
|
116
|
+
${app}
|
|
117
|
+
</ReduxProvider>`;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
/*modifyEntry(setupConfig) {
|
|
123
|
+
let hasLoading = false
|
|
124
|
+
const imports: string[] = []
|
|
125
|
+
const pageLoadingPath = path.posix.join(
|
|
126
|
+
setupConfig.sourceDir,
|
|
127
|
+
'layout/PageLoading.tsx',
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
if (fs.existsSync(pageLoadingPath)) {
|
|
131
|
+
hasLoading = true
|
|
132
|
+
imports.push("import PageLoading from '@/layout/PageLoading'")
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
imports,
|
|
137
|
+
reactImports: ['Suspense'],
|
|
138
|
+
appWrap(app) {
|
|
139
|
+
return `<Suspense fallback={${
|
|
140
|
+
hasLoading ? '<PageLoading />' : '<div />'
|
|
141
|
+
}}>
|
|
142
|
+
${app}
|
|
143
|
+
</Suspense>`
|
|
144
|
+
},
|
|
145
|
+
}
|
|
146
|
+
},*/
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
150
|
+
0 && (module.exports = {
|
|
151
|
+
createLComedyPluginReduxToolkit
|
|
152
|
+
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var __async = (__this, __arguments, generator) => {
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
var fulfilled = (value) => {
|
|
32
|
+
try {
|
|
33
|
+
step(generator.next(value));
|
|
34
|
+
} catch (e) {
|
|
35
|
+
reject(e);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var rejected = (value) => {
|
|
39
|
+
try {
|
|
40
|
+
step(generator.throw(value));
|
|
41
|
+
} catch (e) {
|
|
42
|
+
reject(e);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
46
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// src/plugins/redux-toolkit/index.ts
|
|
51
|
+
var redux_toolkit_exports = {};
|
|
52
|
+
__export(redux_toolkit_exports, {
|
|
53
|
+
default: () => createLComedyPluginReduxToolkit
|
|
54
|
+
});
|
|
55
|
+
module.exports = __toCommonJS(redux_toolkit_exports);
|
|
56
|
+
|
|
57
|
+
// src/plugins/redux-toolkit/createLComedyPluginReduxToolkit.ts
|
|
58
|
+
var import_fs_extra = __toESM(require("fs-extra"));
|
|
59
|
+
var import_path = __toESM(require("path"));
|
|
60
|
+
var import_fast_glob = __toESM(require("fast-glob"));
|
|
61
|
+
function createLComedyPluginReduxToolkit() {
|
|
62
|
+
return {
|
|
63
|
+
name: "l-comedy-plugin-redux-toolkit",
|
|
64
|
+
generateFiles(setupConfig) {
|
|
65
|
+
return __async(this, null, function* () {
|
|
66
|
+
var _a2;
|
|
67
|
+
const sliceDir = ((_a2 = setupConfig.userConfig.reduxToolkit) == null ? void 0 : _a2.slicesDir) || `store/slice`;
|
|
68
|
+
const entires = yield (0, import_fast_glob.default)([`${sliceDir}/*.ts`, "!**/*.tsx"], {
|
|
69
|
+
cwd: setupConfig.sourcePath,
|
|
70
|
+
onlyFiles: true
|
|
71
|
+
});
|
|
72
|
+
const fileMap = entires.map((filePath) => ({
|
|
73
|
+
name: import_path.default.parse(filePath).name,
|
|
74
|
+
filePath
|
|
75
|
+
}));
|
|
76
|
+
import_fs_extra.default.outputFileSync(
|
|
77
|
+
import_path.default.posix.join(setupConfig.workDir, "runtimes", "redux/store.ts"),
|
|
78
|
+
`import { configureStore } from '@reduxjs/toolkit';
|
|
79
|
+
import {
|
|
80
|
+
useDispatch,
|
|
81
|
+
useSelector,
|
|
82
|
+
useStore,
|
|
83
|
+
} from 'react-redux';
|
|
84
|
+
import type { TypedUseSelectorHook } from 'react-redux';
|
|
85
|
+
|
|
86
|
+
// \u5BFC\u5165\u6240\u6709 slice reducer
|
|
87
|
+
${fileMap.map((item) => `import ${item.name}Reducer from '@/${sliceDir}/${item.name}';`).join("\n")}
|
|
88
|
+
|
|
89
|
+
// \u521B\u5EFA store
|
|
90
|
+
export const store = configureStore({
|
|
91
|
+
reducer: {
|
|
92
|
+
${fileMap.map((item) => `${item.name}: ${item.name}Reducer,`).join("\n")}
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export type RootState = ReturnType<typeof store.getState>;
|
|
97
|
+
export type AppDispatch = typeof store.dispatch;
|
|
98
|
+
|
|
99
|
+
export const useAppDispatch = () => useDispatch<AppDispatch>();
|
|
100
|
+
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
|
|
101
|
+
export const useAppStore = () => useStore<RootState>();
|
|
102
|
+
`
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
modifyEntry() {
|
|
107
|
+
return __async(this, null, function* () {
|
|
108
|
+
return {
|
|
109
|
+
imports: [
|
|
110
|
+
`import { Provider as ReduxProvider } from 'react-redux'`,
|
|
111
|
+
`import { store as reduxStore } from './runtimes/redux/store'`
|
|
112
|
+
],
|
|
113
|
+
runtimeExports: [
|
|
114
|
+
`export { useAppSelector, useAppDispatch, useAppStore } from './runtimes/redux/store'`
|
|
115
|
+
],
|
|
116
|
+
appWrap(app) {
|
|
117
|
+
return `<ReduxProvider store={reduxStore}>
|
|
118
|
+
${app}
|
|
119
|
+
</ReduxProvider>`;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/*modifyEntry(setupConfig) {
|
|
125
|
+
let hasLoading = false
|
|
126
|
+
const imports: string[] = []
|
|
127
|
+
const pageLoadingPath = path.posix.join(
|
|
128
|
+
setupConfig.sourceDir,
|
|
129
|
+
'layout/PageLoading.tsx',
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
if (fs.existsSync(pageLoadingPath)) {
|
|
133
|
+
hasLoading = true
|
|
134
|
+
imports.push("import PageLoading from '@/layout/PageLoading'")
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return {
|
|
138
|
+
imports,
|
|
139
|
+
reactImports: ['Suspense'],
|
|
140
|
+
appWrap(app) {
|
|
141
|
+
return `<Suspense fallback={${
|
|
142
|
+
hasLoading ? '<PageLoading />' : '<div />'
|
|
143
|
+
}}>
|
|
144
|
+
${app}
|
|
145
|
+
</Suspense>`
|
|
146
|
+
},
|
|
147
|
+
}
|
|
148
|
+
},*/
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -16,7 +16,11 @@ interface UserConfig {
|
|
|
16
16
|
basename?: string
|
|
17
17
|
routes?: RouteConfig[]
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
reduxToolkit?: {
|
|
20
|
+
/** 相对于@ */
|
|
21
|
+
slicesDir?: string
|
|
22
|
+
}
|
|
23
|
+
plugins?: Array<'route' | 'redux-toolkit' | LComedyPlugin>
|
|
20
24
|
rspackConfig?: Configuration
|
|
21
25
|
sourceDir?: string
|
|
22
26
|
output?: string
|
|
@@ -29,11 +33,11 @@ interface LComedyPlugin {
|
|
|
29
33
|
name: string
|
|
30
34
|
generateFiles?: (setupConfig: SetupConfigPlugin) => Promise<void> | viod
|
|
31
35
|
modifyEntry?: (
|
|
32
|
-
setupConfig: SetupConfigPlugin
|
|
36
|
+
setupConfig: SetupConfigPlugin,
|
|
33
37
|
) => EntryModifier | Promise<EntryModifier>
|
|
34
38
|
rspackConfig?: (
|
|
35
39
|
rspackConfig: Configuration,
|
|
36
|
-
setupConfig: SetupConfig
|
|
40
|
+
setupConfig: SetupConfig,
|
|
37
41
|
) => Configuration | Promise<Configuration>
|
|
38
42
|
runtimeExports?: string[]
|
|
39
43
|
}
|
|
@@ -72,6 +76,7 @@ type SetupConfigPlugin = Omit<SetupConfig, 'plugins'>
|
|
|
72
76
|
|
|
73
77
|
interface EntryModifier {
|
|
74
78
|
imports?: string[]
|
|
79
|
+
runtimeExports?: string[]
|
|
75
80
|
reactImports?: string[]
|
|
76
81
|
beforeRender?: string
|
|
77
82
|
afterRender?: string
|
package/dist/run.js
CHANGED
|
@@ -130,6 +130,15 @@ import { createRoot } from 'react-dom/client';
|
|
|
130
130
|
entryCode += m.afterRender + "\n";
|
|
131
131
|
}
|
|
132
132
|
});
|
|
133
|
+
yield import_fs_extra.default.outputFile(
|
|
134
|
+
import_path.default.posix.join(targetDir, "exports.ts"),
|
|
135
|
+
`${modifiers.filter((item) => item.runtimeExports).map(
|
|
136
|
+
(item) => {
|
|
137
|
+
var _a2;
|
|
138
|
+
return `${(_a2 = item.runtimeExports) == null ? void 0 : _a2.map((exportStr) => exportStr).join("\n")}`;
|
|
139
|
+
}
|
|
140
|
+
).join("\n")}`
|
|
141
|
+
);
|
|
133
142
|
yield import_fs_extra.default.outputFile(import_path.default.posix.join(targetDir, "entry.tsx"), entryCode);
|
|
134
143
|
});
|
|
135
144
|
}
|
|
@@ -167,7 +176,9 @@ function createLComedyPluginAppConfig() {
|
|
|
167
176
|
transpileOnly: true,
|
|
168
177
|
compilerOptions: {
|
|
169
178
|
paths: {
|
|
170
|
-
|
|
179
|
+
// TODO: 使用变量
|
|
180
|
+
"@/*": ["src/*"],
|
|
181
|
+
"@@/*": [".comedy/*"]
|
|
171
182
|
}
|
|
172
183
|
}
|
|
173
184
|
}
|
|
@@ -218,7 +229,8 @@ function createLComedyPluginAppConfig() {
|
|
|
218
229
|
patterns: [
|
|
219
230
|
{
|
|
220
231
|
from: publicDir,
|
|
221
|
-
to: "."
|
|
232
|
+
to: ".",
|
|
233
|
+
noErrorOnMissing: true
|
|
222
234
|
}
|
|
223
235
|
]
|
|
224
236
|
})
|
|
@@ -454,7 +466,8 @@ function setup(userConfig, options) {
|
|
|
454
466
|
resolve: {
|
|
455
467
|
extensions: [".ts", ".tsx", ".js", ".jsx"],
|
|
456
468
|
alias: {
|
|
457
|
-
"@": setupConfig.sourcePath
|
|
469
|
+
"@": setupConfig.sourcePath,
|
|
470
|
+
"@@": setupConfig.workPath
|
|
458
471
|
}
|
|
459
472
|
}
|
|
460
473
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@l-comedy/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"commander": "^14.0.2",
|
|
41
41
|
"css-loader": "7.1.2",
|
|
42
42
|
"esbuild": "^0.27.1",
|
|
43
|
+
"fast-glob": "^3.3.3",
|
|
43
44
|
"fs-extra": "^11.3.2",
|
|
44
45
|
"html-webpack-plugin": "^5.6.5",
|
|
45
46
|
"less": "4.4.2",
|
|
@@ -50,8 +51,10 @@
|
|
|
50
51
|
},
|
|
51
52
|
"optionalDependencies": {
|
|
52
53
|
"@l-comedy/jest-preset": "^0.1.0",
|
|
54
|
+
"@reduxjs/toolkit": "^2.11.2",
|
|
53
55
|
"react": "^18.0.0 || ^19.0.0",
|
|
54
56
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
57
|
+
"react-redux": "^9.2.0",
|
|
55
58
|
"react-router": "^7.0.0",
|
|
56
59
|
"tsup": "^8.5.1"
|
|
57
60
|
},
|