@airiot/cli 1.0.13 → 1.0.15
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/package.json +1 -1
- package/scripts/start.js +1 -1
- package/vite-plugin/externals.js +0 -2
- package/vite-plugin/html.js +1 -1
- package/vite-plugin/importmap.js +28 -28
- package/vite-plugin/importmaps.js +5 -43
- package/vite-plugin/index.js +4 -1
- package/vite-plugin/plugin.js +5 -5
package/package.json
CHANGED
package/scripts/start.js
CHANGED
|
@@ -25,7 +25,7 @@ console.log(chalk.green('[iot:envs] 请求 IOT_URL 为: ' + host + ', 基础路
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
if (!(baseUrl.startsWith('http://') || baseUrl.startsWith('https://') || baseUrl.startsWith('//'))) {
|
|
28
|
-
proxy[baseUrl + '/node_modules/@airiot'] = {
|
|
28
|
+
proxy[baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'node_modules/@airiot'] = {
|
|
29
29
|
target: host,
|
|
30
30
|
changeOrigin: true
|
|
31
31
|
}
|
package/vite-plugin/externals.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
"react": "React",
|
|
3
3
|
"react-dom": "ReactDOM",
|
|
4
|
-
"react/jsx-runtime": "ReactJSXRuntime",
|
|
5
|
-
"react/jsx-dev-runtime": "ReactJSXDevRuntime",
|
|
6
4
|
"react-dnd": "ReactDnD",
|
|
7
5
|
"react-dnd-html5-backend": "ReactDnDHTML5Backend",
|
|
8
6
|
"react-router": "ReactRouter",
|
package/vite-plugin/html.js
CHANGED
package/vite-plugin/importmap.js
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
export default {
|
|
2
|
-
"react": "
|
|
3
|
-
"react/jsx-runtime": "
|
|
4
|
-
"react/jsx-dev-runtime": "
|
|
5
|
-
"react-dom": "
|
|
6
|
-
"react-dom/client": "
|
|
2
|
+
"react": "node_modules/@airiot/dll/esm/react.js",
|
|
3
|
+
"react/jsx-runtime": "node_modules/@airiot/dll/esm/react.js",
|
|
4
|
+
"react/jsx-dev-runtime": "node_modules/@airiot/dll/esm/react.js",
|
|
5
|
+
"react-dom": "node_modules/@airiot/dll/esm/react.js",
|
|
6
|
+
"react-dom/client": "node_modules/@airiot/dll/esm/react.js",
|
|
7
7
|
|
|
8
8
|
// React Router
|
|
9
|
-
"history": "
|
|
10
|
-
"react-router": "
|
|
11
|
-
"react-router-dom": "
|
|
9
|
+
"history": "node_modules/@airiot/dll/esm/history.js",
|
|
10
|
+
"react-router": "node_modules/@airiot/dll/esm/react-router.js",
|
|
11
|
+
"react-router-dom": "node_modules/@airiot/dll/esm/react-router-dom.js",
|
|
12
12
|
|
|
13
13
|
// React DnD
|
|
14
|
-
"react-dnd": "
|
|
15
|
-
"react-dnd-html5-backend": "
|
|
14
|
+
"react-dnd": "node_modules/@airiot/dll/esm/react-dnd_.js",
|
|
15
|
+
"react-dnd-html5-backend": "node_modules/@airiot/dll/esm/react-dnd-html5-backend_.js",
|
|
16
16
|
|
|
17
17
|
// Utility Libraries
|
|
18
|
-
"lodash": "
|
|
19
|
-
"async": "
|
|
20
|
-
"moment": "
|
|
21
|
-
"dayjs": "
|
|
18
|
+
"lodash": "node_modules/@airiot/dll/esm/lodash.js",
|
|
19
|
+
"async": "node_modules/@airiot/dll/esm/async.js",
|
|
20
|
+
"moment": "node_modules/@airiot/dll/esm/moment.js",
|
|
21
|
+
"dayjs": "node_modules/@airiot/dll/esm/dayjs.js",
|
|
22
22
|
|
|
23
23
|
// Excel
|
|
24
|
-
"xlsx": "
|
|
24
|
+
"xlsx": "node_modules/@airiot/dll/esm/xlsx_.js",
|
|
25
25
|
|
|
26
26
|
// Jotai State Management
|
|
27
|
-
"jotai": "
|
|
28
|
-
"jotai/utils": "
|
|
27
|
+
"jotai": "node_modules/@airiot/dll/esm/jotai.js",
|
|
28
|
+
"jotai/utils": "node_modules/@airiot/dll/esm/jotai/utils.js",
|
|
29
29
|
|
|
30
30
|
// Ant Design
|
|
31
|
-
"antd": "
|
|
32
|
-
"@ant-design/icons": "
|
|
33
|
-
// "xui": "
|
|
31
|
+
"antd": "node_modules/@airiot/dll/esm/antd.js",
|
|
32
|
+
"@ant-design/icons": "node_modules/@airiot/dll/esm/@ant-design/icons.js",
|
|
33
|
+
// "xui": "node_modules/@airiot/dll/esm/xui.js",
|
|
34
34
|
|
|
35
35
|
// Xadmin Libraries
|
|
36
|
-
"xadmin": "
|
|
37
|
-
"xadmin-i18n": "
|
|
38
|
-
"xadmin-ui": "
|
|
39
|
-
"xadmin-form": "
|
|
40
|
-
"xadmin-model": "
|
|
41
|
-
"xadmin-auth": "
|
|
42
|
-
"xadmin-antd": "
|
|
43
|
-
// "xadmin-xui": "
|
|
36
|
+
"xadmin": "node_modules/@airiot/dll/esm/xadmin.js",
|
|
37
|
+
"xadmin-i18n": "node_modules/@airiot/dll/esm/xadmin-i18n.js",
|
|
38
|
+
"xadmin-ui": "node_modules/@airiot/dll/esm/xadmin-ui.js",
|
|
39
|
+
"xadmin-form": "node_modules/@airiot/dll/esm/xadmin-form.js",
|
|
40
|
+
"xadmin-model": "node_modules/@airiot/dll/esm/xadmin-model.js",
|
|
41
|
+
"xadmin-auth": "node_modules/@airiot/dll/esm/xadmin-auth.js",
|
|
42
|
+
"xadmin-antd": "node_modules/@airiot/dll/esm/xadmin-antd.js",
|
|
43
|
+
// "xadmin-xui": "node_modules/@airiot/dll/esm/xadmin-xui.js"
|
|
44
44
|
}
|
|
@@ -46,7 +46,8 @@ export default function importMapPlugin(
|
|
|
46
46
|
alias: Object.keys(resolvedImports).map((libName) => {
|
|
47
47
|
if(externals[libName]) {
|
|
48
48
|
const libPath = path.join(externalCacheDir, `${libName.replace(/\//g, '_')}.js`);
|
|
49
|
-
|
|
49
|
+
const gname = externals[libName];
|
|
50
|
+
writeFileSync(libPath, `module.exports = { ...${gname}, __esModule: true };`);
|
|
50
51
|
return {
|
|
51
52
|
find: new RegExp(`^${libName}$`),
|
|
52
53
|
replacement: libPath
|
|
@@ -59,50 +60,11 @@ export default function importMapPlugin(
|
|
|
59
60
|
},
|
|
60
61
|
|
|
61
62
|
transformIndexHtml(html) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
const scriptTag = `<script type="module" async>${Object.keys(resolvedImports).map(libName => externals[libName] ?
|
|
64
|
+
`import("${libName}").then(m => window.${externals[libName]} = m);` : '').join(' ')}</script>`;
|
|
65
|
+
// `import * as ${externals[libName]} from "${libName}"; window.${externals[libName]} = { ...${externals[libName]} };` : '').join(' ')}</script>`;
|
|
65
66
|
return html.replace("</head>", `${scriptTag}</head>`);
|
|
66
67
|
},
|
|
67
68
|
|
|
68
|
-
// handleHotUpdate({ file, server }) {
|
|
69
|
-
// if (
|
|
70
|
-
// importMapPath &&
|
|
71
|
-
// path.resolve(file) === path.resolve(process.cwd(), importMapPath)
|
|
72
|
-
// ) {
|
|
73
|
-
// try {
|
|
74
|
-
// const fileContents = fs.readFileSync(file, "utf-8");
|
|
75
|
-
// const parsedData = JSON.parse(fileContents);
|
|
76
|
-
|
|
77
|
-
// if (parsedData.imports) {
|
|
78
|
-
// resolvedImports = parsedData.imports;
|
|
79
|
-
// console.log(
|
|
80
|
-
// "[vite-plugin-import-map] Updated import map on the fly:",
|
|
81
|
-
// resolvedImports
|
|
82
|
-
// );
|
|
83
|
-
// }
|
|
84
|
-
|
|
85
|
-
// if (autoRestart) {
|
|
86
|
-
// console.log(
|
|
87
|
-
// "[vite-plugin-import-map] Restarting Vite server to apply changes..."
|
|
88
|
-
// );
|
|
89
|
-
// server.restart();
|
|
90
|
-
// } else {
|
|
91
|
-
// console.log(
|
|
92
|
-
// "[vite-plugin-import-map] Import map updated. Please restart Vite manually to apply changes."
|
|
93
|
-
// );
|
|
94
|
-
// }
|
|
95
|
-
|
|
96
|
-
// server.ws.send({
|
|
97
|
-
// type: "full-reload",
|
|
98
|
-
// });
|
|
99
|
-
// } catch (error) {
|
|
100
|
-
// console.error(
|
|
101
|
-
// "[vite-plugin-import-map] Error reading or parsing import-map.json:",
|
|
102
|
-
// error
|
|
103
|
-
// );
|
|
104
|
-
// }
|
|
105
|
-
// }
|
|
106
|
-
// },
|
|
107
69
|
};
|
|
108
70
|
}
|
package/vite-plugin/index.js
CHANGED
|
@@ -29,7 +29,10 @@ const getPlugins = async (mode) => {
|
|
|
29
29
|
}),
|
|
30
30
|
dllMode == "esm" && importMapPlugin({
|
|
31
31
|
imports: importmap,
|
|
32
|
-
externals
|
|
32
|
+
externals: { ...externals,
|
|
33
|
+
"react/jsx-runtime": "ReactJSXRuntime",
|
|
34
|
+
"react/jsx-dev-runtime": "ReactJSXDevRuntime",
|
|
35
|
+
}
|
|
33
36
|
}),
|
|
34
37
|
dllMode == "umd" && createExternal({
|
|
35
38
|
externals
|
package/vite-plugin/plugin.js
CHANGED
|
@@ -16,17 +16,17 @@ const findModule = (scripts, packageName) => {
|
|
|
16
16
|
|
|
17
17
|
const loadOnline = true
|
|
18
18
|
const host = getHost()
|
|
19
|
-
const basePath = getBaseUrl() + '/node_modules'
|
|
20
19
|
const baseUrl = getBaseUrl()
|
|
20
|
+
const basePath = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'node_modules'
|
|
21
21
|
|
|
22
22
|
const importMap = Object.fromEntries(
|
|
23
23
|
Object.entries(imports).map(([key, value]) => {
|
|
24
|
-
return [key, baseUrl + value];
|
|
24
|
+
return [key, baseUrl + (baseUrl.endsWith('/') ? '' : '/') + value];
|
|
25
25
|
})
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
const defaultModules = [
|
|
29
|
-
'@airiot/i18n', '@airiot/core'
|
|
29
|
+
'@airiot/i18n', '@airiot/core', '@airiot/theme'
|
|
30
30
|
]
|
|
31
31
|
|
|
32
32
|
let scripts, frontScripts;
|
|
@@ -58,8 +58,8 @@ const loadPackageScripts = async () => {
|
|
|
58
58
|
|
|
59
59
|
const packageScripts = await Promise.all(packageNames.map(async packageName => {
|
|
60
60
|
if(packageName != appPackage.name && !findModule(scripts, packageName)) {
|
|
61
|
-
const packagePath = basePath + '/' + packageName
|
|
62
|
-
|
|
61
|
+
const packagePath = basePath + (basePath.endsWith('/') ? '' : '/') + packageName
|
|
62
|
+
|
|
63
63
|
if (loadOnline) {
|
|
64
64
|
try {
|
|
65
65
|
let pkgUrl = packagePath.replace(/\/+$/,'') + '/package.json'
|