@moneko/core 3.28.9 → 3.29.1
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/lib/bin/convert.d.mts +36 -0
- package/lib/bin/convert.mjs +0 -0
- package/lib/bin/utils/setup-swcrc.d.mts +1 -0
- package/lib/bin/utils/setup-swcrc.mjs +1 -1
- package/lib/entry/react.d.mts +13 -0
- package/lib/entry/react.mjs +41 -0
- package/lib/loader/ast.json +388 -0
- package/lib/loader/demo.ast.json +1528 -0
- package/package.json +7 -6
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import { copyFile, ink, println, scanFolderSync, updateFile } from '@moneko/utils';
|
|
3
|
+
import { JsMinifyOptions, type Options, type Output, transformFile } from '@swc/core';
|
|
4
|
+
declare function getOutfilePath(outDir: string, file: string, outFileExtension?: string);
|
|
5
|
+
interface ConvertOptions {
|
|
6
|
+
outDir: string;
|
|
7
|
+
inputDir: string;
|
|
8
|
+
options: Options;
|
|
9
|
+
ignore?: RegExp[];
|
|
10
|
+
extensions?: string[];
|
|
11
|
+
copy?: boolean;
|
|
12
|
+
quiet?: boolean;
|
|
13
|
+
outputExtension?: string;
|
|
14
|
+
}
|
|
15
|
+
interface ConvertResult {
|
|
16
|
+
duration: number;
|
|
17
|
+
compiled: string[];
|
|
18
|
+
copied: string[];
|
|
19
|
+
failed: string[];
|
|
20
|
+
}
|
|
21
|
+
interface ConvertOutput extends Output {
|
|
22
|
+
output?: string;
|
|
23
|
+
}
|
|
24
|
+
declare const normalizeExtension: Record<string, string>;
|
|
25
|
+
declare const jscMinify: JsMinifyOptions;
|
|
26
|
+
declare async function convert({ ignore = [], quiet = true, copy = true, outDir, outputExtension, inputDir, options, extensions = [
|
|
27
|
+
'.ts',
|
|
28
|
+
'.js',
|
|
29
|
+
'.tsx',
|
|
30
|
+
'.jsx',
|
|
31
|
+
'.mts',
|
|
32
|
+
'.mjs',
|
|
33
|
+
'.cts',
|
|
34
|
+
'.cjs'
|
|
35
|
+
] }: ConvertOptions);
|
|
36
|
+
export default convert;
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"../../commom/require.mjs";export function getSwcOption(
|
|
1
|
+
import e from"../../commom/require.mjs";import{cwd as o}from"./config.mjs";export function getSwcOption(r){let s="solid"===r;return{module:{type:"es6"},minify:!0,jsc:{minify:{format:{comments:!1},ecma:2015,compress:{drop_console:!0,drop_debugger:!0,global_defs:{"@alert":"console.log"},pure_funcs:["console.log","console.warn","console.error","console.info"],ecma:2015,toplevel:!1,module:!1,ie8:!1,keep_classnames:void 0,keep_fnames:!1,top_retain:[],keep_infinity:!0},mangle:!0},parser:{syntax:"typescript",decorators:!0,dynamicImport:!0,tsx:!0},loose:!0,target:"es2022",transform:{legacyDecorator:!0,decoratorMetadata:!0,react:{runtime:"automatic",throwIfNamespace:!0,useBuiltins:!0,refresh:"react"===r,development:!1,importSource:s?"solid-js/h":void 0}},experimental:{plugins:[[e.resolve("@moneko/raw-import"),{rootDir:o}],[e.resolve("@moneko/transform-imports"),{"@moneko/common":{transform:"@moneko/common/lib/${member}"},lodash:{transform:"lodash/${member}"},"@ant-design/icons":{transform:"es/icons/${member}"},antd:{transform:"es/${member}",memberTransformers:["dashed_case"]},"neko-ui":{transform:"es/${member}",memberTransformers:["dashed_case"]}}],s&&[e.resolve("@moneko/jsx-dom-expressions"),{moduleName:"solid-js/web",builtIns:["For","Show","Switch","Match","Suspense","SuspenseList","Portal","Index","Dynamic","ErrorBoundary"],contextToCustomElements:!0,wrapConditionals:!0,generate:"dom",hydratable:!1}]].filter(Boolean)}},sourceMaps:!0,exclude:["__tests__/","examples/","\\.d\\.ts$"]}}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { transformSync } from '@swc/core';
|
|
2
|
+
import swcrc, { SwcOption } from '../options/swcrc.mjs';
|
|
3
|
+
import { isDev } from '../process-env.mjs';
|
|
4
|
+
import info from '../vm/info.mjs';
|
|
5
|
+
declare const version: number;
|
|
6
|
+
declare const ReactDomPath: string;
|
|
7
|
+
declare const isHashRouter: boolean;
|
|
8
|
+
declare const v7Future: Record<string, boolean | undefined>;
|
|
9
|
+
declare const createRouter: string;
|
|
10
|
+
declare const code: string;
|
|
11
|
+
declare const swcOption: SwcOption;
|
|
12
|
+
declare const reactRenderApp: string;
|
|
13
|
+
export default reactRenderApp;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import{transformSync as e}from"@swc/core";import r from"../options/swcrc.mjs";import{isDev as t}from"../process-env.mjs";import o from"../vm/info.mjs";let a=parseFloat(o.frameworkVersion),n="hash"===o.routerMode,s=Object.assign({v7_relativeSplatPath:!1},"browser"===o.routerMode?{v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:o.ssr,v7_skipActionErrorRevalidation:!1}:{}),c=n?"createHashRouter":"createBrowserRouter",p=`import React, { StrictMode, useRef, type ReactElement } from 'react';
|
|
2
|
+
import Fallback from '@app/fallback';
|
|
3
|
+
import routes from '@app/routes';
|
|
4
|
+
import ReactDOM from '${a<18?"react-dom":"react-dom/client"}';
|
|
5
|
+
import { RouterProvider, ${c} } from 'react-router-dom';
|
|
6
|
+
|
|
7
|
+
type RenderAppProps = {
|
|
8
|
+
container?: HTMLElement;
|
|
9
|
+
basename?: string;
|
|
10
|
+
fallback?: ReactElement;
|
|
11
|
+
language?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function App(props: RenderAppProps) {
|
|
15
|
+
const v7Future = useRef(${JSON.stringify(s)});
|
|
16
|
+
return (
|
|
17
|
+
<StrictMode>
|
|
18
|
+
<RouterProvider
|
|
19
|
+
router={${c}(routes, {
|
|
20
|
+
basename: ${n?"/":"props.basename"},
|
|
21
|
+
window: window,
|
|
22
|
+
future: v7Future.current,
|
|
23
|
+
})}
|
|
24
|
+
future={{
|
|
25
|
+
/** 这使用 useTransition 而不是 useState 来更新路由器状态 */
|
|
26
|
+
v7_startTransition: false,
|
|
27
|
+
}}
|
|
28
|
+
fallbackElement={Fallback && <Fallback />}
|
|
29
|
+
/>
|
|
30
|
+
</StrictMode>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function renderApp(props: RenderAppProps = {}) {
|
|
35
|
+
const { container, basename = "${o.base}", language, ...args } = props;
|
|
36
|
+
const _container = container?.querySelector('#root') || document.getElementById('root');
|
|
37
|
+
${"micro"===o.type?"window.mainApp = { ...args, container: _container as HTMLElement };":""}
|
|
38
|
+
${a<18?`ReactDOM.${t?"render":"hydrate"}(<App basename={basename} language={language} />, _container);return () => ReactDOM.unmountComponentAtNode(_container as Element);`:"const instance = ReactDOM.createRoot(_container as HTMLElement);instance.render(<App basename={basename} language={language} />);return instance.unmount;"}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default renderApp;`,i=r(o.ssr);delete i.sync,delete i.parseMap;let m=e(p,i).code;console.log(m);export default m;
|
|
@@ -0,0 +1,388 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "Module",
|
|
3
|
+
"span": {
|
|
4
|
+
"start": 1194957,
|
|
5
|
+
"end": 1195243,
|
|
6
|
+
"ctxt": 0
|
|
7
|
+
},
|
|
8
|
+
"body": [
|
|
9
|
+
{
|
|
10
|
+
"type": "ImportDeclaration",
|
|
11
|
+
"span": {
|
|
12
|
+
"start": 1194957,
|
|
13
|
+
"end": 1194991,
|
|
14
|
+
"ctxt": 0
|
|
15
|
+
},
|
|
16
|
+
"specifiers": [
|
|
17
|
+
{
|
|
18
|
+
"type": "ImportSpecifier",
|
|
19
|
+
"span": {
|
|
20
|
+
"start": 1194966,
|
|
21
|
+
"end": 1194969,
|
|
22
|
+
"ctxt": 0
|
|
23
|
+
},
|
|
24
|
+
"local": {
|
|
25
|
+
"type": "Identifier",
|
|
26
|
+
"span": {
|
|
27
|
+
"start": 1194966,
|
|
28
|
+
"end": 1194969,
|
|
29
|
+
"ctxt": 2
|
|
30
|
+
},
|
|
31
|
+
"value": "css",
|
|
32
|
+
"optional": false
|
|
33
|
+
},
|
|
34
|
+
"imported": null,
|
|
35
|
+
"isTypeOnly": false
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"source": {
|
|
39
|
+
"type": "StringLiteral",
|
|
40
|
+
"span": {
|
|
41
|
+
"start": 1194977,
|
|
42
|
+
"end": 1194990,
|
|
43
|
+
"ctxt": 0
|
|
44
|
+
},
|
|
45
|
+
"value": "@moneko/css",
|
|
46
|
+
"raw": "'@moneko/css'"
|
|
47
|
+
},
|
|
48
|
+
"typeOnly": false,
|
|
49
|
+
"with": null,
|
|
50
|
+
"phase": "evaluation"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"type": "ImportDeclaration",
|
|
54
|
+
"span": {
|
|
55
|
+
"start": 1194992,
|
|
56
|
+
"end": 1195030,
|
|
57
|
+
"ctxt": 0
|
|
58
|
+
},
|
|
59
|
+
"specifiers": [
|
|
60
|
+
{
|
|
61
|
+
"type": "ImportSpecifier",
|
|
62
|
+
"span": {
|
|
63
|
+
"start": 1195001,
|
|
64
|
+
"end": 1195011,
|
|
65
|
+
"ctxt": 0
|
|
66
|
+
},
|
|
67
|
+
"local": {
|
|
68
|
+
"type": "Identifier",
|
|
69
|
+
"span": {
|
|
70
|
+
"start": 1195001,
|
|
71
|
+
"end": 1195011,
|
|
72
|
+
"ctxt": 2
|
|
73
|
+
},
|
|
74
|
+
"value": "createMemo",
|
|
75
|
+
"optional": false
|
|
76
|
+
},
|
|
77
|
+
"imported": null,
|
|
78
|
+
"isTypeOnly": false
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"source": {
|
|
82
|
+
"type": "StringLiteral",
|
|
83
|
+
"span": {
|
|
84
|
+
"start": 1195019,
|
|
85
|
+
"end": 1195029,
|
|
86
|
+
"ctxt": 0
|
|
87
|
+
},
|
|
88
|
+
"value": "solid-js",
|
|
89
|
+
"raw": "'solid-js'"
|
|
90
|
+
},
|
|
91
|
+
"typeOnly": false,
|
|
92
|
+
"with": null,
|
|
93
|
+
"phase": "evaluation"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"type": "FunctionDeclaration",
|
|
97
|
+
"identifier": {
|
|
98
|
+
"type": "Identifier",
|
|
99
|
+
"span": {
|
|
100
|
+
"start": 1195040,
|
|
101
|
+
"end": 1195041,
|
|
102
|
+
"ctxt": 2
|
|
103
|
+
},
|
|
104
|
+
"value": "A",
|
|
105
|
+
"optional": false
|
|
106
|
+
},
|
|
107
|
+
"declare": false,
|
|
108
|
+
"params": [],
|
|
109
|
+
"decorators": [],
|
|
110
|
+
"span": {
|
|
111
|
+
"start": 1195031,
|
|
112
|
+
"end": 1195225,
|
|
113
|
+
"ctxt": 3
|
|
114
|
+
},
|
|
115
|
+
"body": {
|
|
116
|
+
"type": "BlockStatement",
|
|
117
|
+
"span": {
|
|
118
|
+
"start": 1195044,
|
|
119
|
+
"end": 1195225,
|
|
120
|
+
"ctxt": 3
|
|
121
|
+
},
|
|
122
|
+
"stmts": [
|
|
123
|
+
{
|
|
124
|
+
"type": "VariableDeclaration",
|
|
125
|
+
"span": {
|
|
126
|
+
"start": 1195050,
|
|
127
|
+
"end": 1195152,
|
|
128
|
+
"ctxt": 0
|
|
129
|
+
},
|
|
130
|
+
"kind": "const",
|
|
131
|
+
"declare": false,
|
|
132
|
+
"declarations": [
|
|
133
|
+
{
|
|
134
|
+
"type": "VariableDeclarator",
|
|
135
|
+
"span": {
|
|
136
|
+
"start": 1195056,
|
|
137
|
+
"end": 1195151,
|
|
138
|
+
"ctxt": 0
|
|
139
|
+
},
|
|
140
|
+
"id": {
|
|
141
|
+
"type": "Identifier",
|
|
142
|
+
"span": {
|
|
143
|
+
"start": 1195056,
|
|
144
|
+
"end": 1195059,
|
|
145
|
+
"ctxt": 3
|
|
146
|
+
},
|
|
147
|
+
"value": "ass",
|
|
148
|
+
"optional": false,
|
|
149
|
+
"typeAnnotation": null
|
|
150
|
+
},
|
|
151
|
+
"init": {
|
|
152
|
+
"type": "CallExpression",
|
|
153
|
+
"span": {
|
|
154
|
+
"start": 1195062,
|
|
155
|
+
"end": 1195151,
|
|
156
|
+
"ctxt": 0
|
|
157
|
+
},
|
|
158
|
+
"callee": {
|
|
159
|
+
"type": "Identifier",
|
|
160
|
+
"span": {
|
|
161
|
+
"start": 1195062,
|
|
162
|
+
"end": 1195072,
|
|
163
|
+
"ctxt": 2
|
|
164
|
+
},
|
|
165
|
+
"value": "createMemo",
|
|
166
|
+
"optional": false
|
|
167
|
+
},
|
|
168
|
+
"arguments": [
|
|
169
|
+
{
|
|
170
|
+
"spread": null,
|
|
171
|
+
"expression": {
|
|
172
|
+
"type": "ArrowFunctionExpression",
|
|
173
|
+
"span": {
|
|
174
|
+
"start": 1195073,
|
|
175
|
+
"end": 1195150,
|
|
176
|
+
"ctxt": 0
|
|
177
|
+
},
|
|
178
|
+
"params": [],
|
|
179
|
+
"body": {
|
|
180
|
+
"type": "BlockStatement",
|
|
181
|
+
"span": {
|
|
182
|
+
"start": 1195077,
|
|
183
|
+
"end": 1195150,
|
|
184
|
+
"ctxt": 4
|
|
185
|
+
},
|
|
186
|
+
"stmts": [
|
|
187
|
+
{
|
|
188
|
+
"type": "VariableDeclaration",
|
|
189
|
+
"span": {
|
|
190
|
+
"start": 1195087,
|
|
191
|
+
"end": 1195126,
|
|
192
|
+
"ctxt": 0
|
|
193
|
+
},
|
|
194
|
+
"kind": "const",
|
|
195
|
+
"declare": false,
|
|
196
|
+
"declarations": [
|
|
197
|
+
{
|
|
198
|
+
"type": "VariableDeclarator",
|
|
199
|
+
"span": {
|
|
200
|
+
"start": 1195093,
|
|
201
|
+
"end": 1195125,
|
|
202
|
+
"ctxt": 0
|
|
203
|
+
},
|
|
204
|
+
"id": {
|
|
205
|
+
"type": "Identifier",
|
|
206
|
+
"span": {
|
|
207
|
+
"start": 1195093,
|
|
208
|
+
"end": 1195094,
|
|
209
|
+
"ctxt": 4
|
|
210
|
+
},
|
|
211
|
+
"value": "s",
|
|
212
|
+
"optional": false,
|
|
213
|
+
"typeAnnotation": null
|
|
214
|
+
},
|
|
215
|
+
"init": {
|
|
216
|
+
"type": "TaggedTemplateExpression",
|
|
217
|
+
"span": {
|
|
218
|
+
"start": 1195097,
|
|
219
|
+
"end": 1195125,
|
|
220
|
+
"ctxt": 0
|
|
221
|
+
},
|
|
222
|
+
"tag": {
|
|
223
|
+
"type": "Identifier",
|
|
224
|
+
"span": {
|
|
225
|
+
"start": 1195097,
|
|
226
|
+
"end": 1195100,
|
|
227
|
+
"ctxt": 2
|
|
228
|
+
},
|
|
229
|
+
"value": "css",
|
|
230
|
+
"optional": false
|
|
231
|
+
},
|
|
232
|
+
"typeParameters": null,
|
|
233
|
+
"template": {
|
|
234
|
+
"type": "TemplateLiteral",
|
|
235
|
+
"span": {
|
|
236
|
+
"start": 1195100,
|
|
237
|
+
"end": 1195125,
|
|
238
|
+
"ctxt": 0
|
|
239
|
+
},
|
|
240
|
+
"expressions": [],
|
|
241
|
+
"quasis": [
|
|
242
|
+
{
|
|
243
|
+
"type": "TemplateElement",
|
|
244
|
+
"span": {
|
|
245
|
+
"start": 1195101,
|
|
246
|
+
"end": 1195124,
|
|
247
|
+
"ctxt": 0
|
|
248
|
+
},
|
|
249
|
+
"tail": true,
|
|
250
|
+
"cooked": "\n color: red;\n ",
|
|
251
|
+
"raw": "\n color: red;\n "
|
|
252
|
+
}
|
|
253
|
+
]
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
"definite": false
|
|
257
|
+
}
|
|
258
|
+
]
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
"type": "ReturnStatement",
|
|
262
|
+
"span": {
|
|
263
|
+
"start": 1195135,
|
|
264
|
+
"end": 1195144,
|
|
265
|
+
"ctxt": 0
|
|
266
|
+
},
|
|
267
|
+
"argument": {
|
|
268
|
+
"type": "Identifier",
|
|
269
|
+
"span": {
|
|
270
|
+
"start": 1195142,
|
|
271
|
+
"end": 1195143,
|
|
272
|
+
"ctxt": 4
|
|
273
|
+
},
|
|
274
|
+
"value": "s",
|
|
275
|
+
"optional": false
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
]
|
|
279
|
+
},
|
|
280
|
+
"async": false,
|
|
281
|
+
"generator": false,
|
|
282
|
+
"typeParameters": null,
|
|
283
|
+
"returnType": null
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
"typeArguments": null
|
|
288
|
+
},
|
|
289
|
+
"definite": false
|
|
290
|
+
}
|
|
291
|
+
]
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"type": "ReturnStatement",
|
|
295
|
+
"span": {
|
|
296
|
+
"start": 1195157,
|
|
297
|
+
"end": 1195223,
|
|
298
|
+
"ctxt": 0
|
|
299
|
+
},
|
|
300
|
+
"argument": {
|
|
301
|
+
"type": "BinaryExpression",
|
|
302
|
+
"span": {
|
|
303
|
+
"start": 1195164,
|
|
304
|
+
"end": 1195222,
|
|
305
|
+
"ctxt": 0
|
|
306
|
+
},
|
|
307
|
+
"operator": "+",
|
|
308
|
+
"left": {
|
|
309
|
+
"type": "TaggedTemplateExpression",
|
|
310
|
+
"span": {
|
|
311
|
+
"start": 1195164,
|
|
312
|
+
"end": 1195216,
|
|
313
|
+
"ctxt": 0
|
|
314
|
+
},
|
|
315
|
+
"tag": {
|
|
316
|
+
"type": "Identifier",
|
|
317
|
+
"span": {
|
|
318
|
+
"start": 1195164,
|
|
319
|
+
"end": 1195167,
|
|
320
|
+
"ctxt": 2
|
|
321
|
+
},
|
|
322
|
+
"value": "css",
|
|
323
|
+
"optional": false
|
|
324
|
+
},
|
|
325
|
+
"typeParameters": null,
|
|
326
|
+
"template": {
|
|
327
|
+
"type": "TemplateLiteral",
|
|
328
|
+
"span": {
|
|
329
|
+
"start": 1195167,
|
|
330
|
+
"end": 1195216,
|
|
331
|
+
"ctxt": 0
|
|
332
|
+
},
|
|
333
|
+
"expressions": [],
|
|
334
|
+
"quasis": [
|
|
335
|
+
{
|
|
336
|
+
"type": "TemplateElement",
|
|
337
|
+
"span": {
|
|
338
|
+
"start": 1195168,
|
|
339
|
+
"end": 1195215,
|
|
340
|
+
"ctxt": 0
|
|
341
|
+
},
|
|
342
|
+
"tail": true,
|
|
343
|
+
"cooked": "\n .body {\n color: red;\n }\n ",
|
|
344
|
+
"raw": "\n .body {\n color: red;\n }\n "
|
|
345
|
+
}
|
|
346
|
+
]
|
|
347
|
+
}
|
|
348
|
+
},
|
|
349
|
+
"right": {
|
|
350
|
+
"type": "Identifier",
|
|
351
|
+
"span": {
|
|
352
|
+
"start": 1195219,
|
|
353
|
+
"end": 1195222,
|
|
354
|
+
"ctxt": 3
|
|
355
|
+
},
|
|
356
|
+
"value": "ass",
|
|
357
|
+
"optional": false
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
]
|
|
362
|
+
},
|
|
363
|
+
"generator": false,
|
|
364
|
+
"async": false,
|
|
365
|
+
"typeParameters": null,
|
|
366
|
+
"returnType": null
|
|
367
|
+
},
|
|
368
|
+
{
|
|
369
|
+
"type": "ExportDefaultExpression",
|
|
370
|
+
"span": {
|
|
371
|
+
"start": 1195226,
|
|
372
|
+
"end": 1195243,
|
|
373
|
+
"ctxt": 0
|
|
374
|
+
},
|
|
375
|
+
"expression": {
|
|
376
|
+
"type": "Identifier",
|
|
377
|
+
"span": {
|
|
378
|
+
"start": 1195241,
|
|
379
|
+
"end": 1195242,
|
|
380
|
+
"ctxt": 2
|
|
381
|
+
},
|
|
382
|
+
"value": "A",
|
|
383
|
+
"optional": false
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
],
|
|
387
|
+
"interpreter": null
|
|
388
|
+
}
|