@airiot/cli 1.0.13 → 1.0.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.
package/package.json
CHANGED
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/importmap.js
CHANGED
|
@@ -12,7 +12,7 @@ export default {
|
|
|
12
12
|
|
|
13
13
|
// React DnD
|
|
14
14
|
"react-dnd": "/node_modules/@airiot/dll/esm/react-dnd_.js",
|
|
15
|
-
"react-dnd-html5-backend": "/node_modules/@airiot/dll/esm/react-dnd-html5-
|
|
15
|
+
"react-dnd-html5-backend": "/node_modules/@airiot/dll/esm/react-dnd-html5-backend_.js",
|
|
16
16
|
|
|
17
17
|
// Utility Libraries
|
|
18
18
|
"lodash": "/node_modules/@airiot/dll/esm/lodash.js",
|
|
@@ -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
|