@hitachivantara/app-shell-vite-plugin 0.5.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/LICENSE +201 -0
- package/README.md +60 -0
- package/dist/esm-externals/react-dom.production.min.js +12 -0
- package/dist/esm-externals/react-dom.production.min.js.map +1 -0
- package/dist/esm-externals/react-router-dom.production.min.js +33 -0
- package/dist/esm-externals/react-router-dom.production.min.js.map +1 -0
- package/dist/esm-externals/react.production.min.js +3 -0
- package/dist/esm-externals/react.production.min.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/vite-importmap-plugin.d.ts +8 -0
- package/dist/vite-importmap-plugin.d.ts.map +1 -0
- package/dist/vite-importmap-plugin.js +170 -0
- package/dist/vite-importmap-plugin.js.map +1 -0
- package/dist/vite-plugin.d.ts +27 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +352 -0
- package/dist/vite-plugin.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import virtual from "@rollup/plugin-virtual";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
5
|
+
import { createRequire } from "node:module";
|
|
6
|
+
import generateImportmap from "./vite-importmap-plugin.js";
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
8
|
+
/**
|
|
9
|
+
* Return the main app (identified by @self)
|
|
10
|
+
* @param appShellConfig The App shell configuration
|
|
11
|
+
*/
|
|
12
|
+
const getMainApp = (appShellConfig) => {
|
|
13
|
+
return appShellConfig.apps.filter(app => app.id === "@self")[0];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Return the public path to be use by vite to launch the application.
|
|
17
|
+
* Value is obtained by returning the baseUrl value of the main app {@link #getMainApp}
|
|
18
|
+
* @param appShellConfig The App shell configuration
|
|
19
|
+
*/
|
|
20
|
+
const getPublicPath = (appShellConfig) => {
|
|
21
|
+
const mainApp = getMainApp(appShellConfig);
|
|
22
|
+
if (!mainApp) {
|
|
23
|
+
return "/";
|
|
24
|
+
}
|
|
25
|
+
const url = mainApp.baseUrl;
|
|
26
|
+
try {
|
|
27
|
+
return new URL(url).pathname;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return url;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Resolves the module name and normalizes slashes to be posix/unix-like forward slashes.
|
|
35
|
+
*
|
|
36
|
+
* @param moduleName The name of the module to be searched for
|
|
37
|
+
* @returns The module path normalized
|
|
38
|
+
*/
|
|
39
|
+
function resolveModule(moduleName) {
|
|
40
|
+
const module = require.resolve(moduleName);
|
|
41
|
+
return module.replace(/\\+/g, "/");
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* This function will find out the module path using node `require.resolve` function
|
|
45
|
+
* and add the suffix param after the folder with module name.
|
|
46
|
+
*
|
|
47
|
+
* @param moduleName "@module/name"
|
|
48
|
+
* @param suffix to be added after the module path
|
|
49
|
+
* @returns the /path/to/@module/name/<suffix>
|
|
50
|
+
*/
|
|
51
|
+
function getModulePath(moduleName, suffix) {
|
|
52
|
+
const moduleNameWithSlashes = `/${moduleName}/`;
|
|
53
|
+
const module = resolveModule(moduleName);
|
|
54
|
+
const modulePosition = module.lastIndexOf(moduleNameWithSlashes);
|
|
55
|
+
return `${module.slice(0, modulePosition + moduleNameWithSlashes.length)}${suffix}`;
|
|
56
|
+
}
|
|
57
|
+
var ViteBuildMode;
|
|
58
|
+
(function (ViteBuildMode) {
|
|
59
|
+
ViteBuildMode["PRODUCTION"] = "production";
|
|
60
|
+
ViteBuildMode["DEVELOPMENT"] = "development";
|
|
61
|
+
})(ViteBuildMode || (ViteBuildMode = {}));
|
|
62
|
+
var ViteCommand;
|
|
63
|
+
(function (ViteCommand) {
|
|
64
|
+
ViteCommand["BUILD"] = "build";
|
|
65
|
+
ViteCommand["SERVE"] = "serve";
|
|
66
|
+
})(ViteCommand || (ViteCommand = {}));
|
|
67
|
+
/**
|
|
68
|
+
* Returns the modules to be created by the build of the app.
|
|
69
|
+
* The list of modules is defined by the app-shell-config.json file routes ( limited to the @self app)
|
|
70
|
+
* The bundles will be created following the original directories structure ( having the src folder path removed)
|
|
71
|
+
*
|
|
72
|
+
* @param root Project root directory.
|
|
73
|
+
* @param appShellConfig The App Shell configuration.
|
|
74
|
+
*/
|
|
75
|
+
function getAppModules(root, appShellConfig) {
|
|
76
|
+
const appModules = {};
|
|
77
|
+
const selfApp = getMainApp(appShellConfig);
|
|
78
|
+
const selfViews = selfApp?.views?.map(view => {
|
|
79
|
+
const bundleName = view.bundle.replace(/^src\//, "");
|
|
80
|
+
return {
|
|
81
|
+
...view,
|
|
82
|
+
bundleName
|
|
83
|
+
};
|
|
84
|
+
}) ?? [];
|
|
85
|
+
selfViews.forEach(view => {
|
|
86
|
+
appModules[view.bundleName] = path.resolve(root, view.bundle);
|
|
87
|
+
});
|
|
88
|
+
const selfModules = selfApp?.modules?.map(module => {
|
|
89
|
+
const bundleName = module.bundle.replace(/^src\//, "");
|
|
90
|
+
return {
|
|
91
|
+
...module,
|
|
92
|
+
bundleName
|
|
93
|
+
};
|
|
94
|
+
}) ?? [];
|
|
95
|
+
selfModules.forEach(module => {
|
|
96
|
+
appModules[module.bundleName] = path.resolve(root, module.bundle);
|
|
97
|
+
});
|
|
98
|
+
console.info("Modules exported by the application bundle:", appModules);
|
|
99
|
+
return appModules;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Process configuration, executing several tasks:
|
|
103
|
+
* - Create rollup configuration to support module creation
|
|
104
|
+
* - Generates final transformed configuration json
|
|
105
|
+
* - "base" value is always "./" for build, and main app baseUrl for preview or dev
|
|
106
|
+
* - Injects the APP_BASE_PATH env prop, to be used by the apps (if required)
|
|
107
|
+
* @param root Project root directory.
|
|
108
|
+
* @param appShellConfig The original App Shell configuration json.
|
|
109
|
+
* @param selfAppName The name of the application bundle being built.
|
|
110
|
+
*/
|
|
111
|
+
function processConfiguration(root, appShellConfig, selfAppName) {
|
|
112
|
+
const finalAppShellConfig = { ...appShellConfig };
|
|
113
|
+
const selfApp = getMainApp(finalAppShellConfig);
|
|
114
|
+
return {
|
|
115
|
+
name: "vite-plugin-appShell-configuration-processor",
|
|
116
|
+
config(config, { command }) {
|
|
117
|
+
const projectRoot = root ?? config.root;
|
|
118
|
+
const publicPath = getPublicPath(appShellConfig);
|
|
119
|
+
return {
|
|
120
|
+
build: {
|
|
121
|
+
rollupOptions: {
|
|
122
|
+
preserveEntrySignatures: "strict",
|
|
123
|
+
input: {
|
|
124
|
+
main: path.resolve(projectRoot, "index.html"),
|
|
125
|
+
...getAppModules(projectRoot, appShellConfig)
|
|
126
|
+
},
|
|
127
|
+
output: {
|
|
128
|
+
entryFileNames: "[name].js"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
// if serve (preview/dev) it uses the baseUrl. Otherwise(build), use ./
|
|
133
|
+
base: command === ViteCommand.SERVE ? publicPath : "./",
|
|
134
|
+
define: {
|
|
135
|
+
...config.define,
|
|
136
|
+
APP_BASE_PATH: JSON.stringify(publicPath)
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
/**
|
|
141
|
+
* Rollup hook with the info for bundle generation
|
|
142
|
+
* It will be used to create a new configuration with:
|
|
143
|
+
* - bundles replace with the final location (e.g. -> "bundle": "src/pages/Main" transformed to "bundle": "pages/Main.js",
|
|
144
|
+
* @param options build options
|
|
145
|
+
* @param bundle bundles information
|
|
146
|
+
*/
|
|
147
|
+
async generateBundle(options, bundle) {
|
|
148
|
+
// obtain the directory (dist) where the new config file will be placed
|
|
149
|
+
let targetDir;
|
|
150
|
+
if (options.dir) {
|
|
151
|
+
targetDir = options.dir;
|
|
152
|
+
}
|
|
153
|
+
else if (options.file) {
|
|
154
|
+
targetDir = path.dirname(options.file);
|
|
155
|
+
}
|
|
156
|
+
if (!targetDir) {
|
|
157
|
+
throw new Error("Please set outputPath, so we can know where to place the json file");
|
|
158
|
+
}
|
|
159
|
+
// create the targetDir if it does not exist
|
|
160
|
+
if (!fs.existsSync(targetDir)) {
|
|
161
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Creating a map with each chunk and the final name. Only the bundles with type=chunck are important
|
|
165
|
+
* Filename do not include the src path at the value
|
|
166
|
+
*/
|
|
167
|
+
const chunks = {};
|
|
168
|
+
Object.keys(bundle).forEach(key => {
|
|
169
|
+
const chunk = bundle[key];
|
|
170
|
+
if (chunk.type === "chunk") {
|
|
171
|
+
const outputChunk = chunk;
|
|
172
|
+
if (outputChunk.isEntry) {
|
|
173
|
+
const { fileName } = outputChunk;
|
|
174
|
+
const { name } = outputChunk;
|
|
175
|
+
chunks[name] = fileName;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
if (selfApp) {
|
|
180
|
+
selfApp.views = selfApp.views?.map(view => {
|
|
181
|
+
const bundleName = view.bundle.replace(/^src\//, "");
|
|
182
|
+
return {
|
|
183
|
+
...view,
|
|
184
|
+
bundle: chunks[bundleName]
|
|
185
|
+
};
|
|
186
|
+
});
|
|
187
|
+
selfApp.modules = selfApp.modules?.map(module => {
|
|
188
|
+
const bundleName = module.bundle.replace(/^src\//, "");
|
|
189
|
+
return {
|
|
190
|
+
...module,
|
|
191
|
+
bundle: chunks[bundleName]
|
|
192
|
+
};
|
|
193
|
+
});
|
|
194
|
+
// replace references to @self with the name of this application bundle
|
|
195
|
+
selfApp.id = selfAppName;
|
|
196
|
+
}
|
|
197
|
+
fs.writeFileSync(path.resolve(targetDir, "app-shell.config.json"), JSON.stringify(finalAppShellConfig));
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Add the <BASE> tag at index.html file. Tag value is obtained by the main app ({@link #getMainApp}) baseUrl ({@link #getPublicPath})‘
|
|
203
|
+
* @param appShellConfig The app shell configuration.
|
|
204
|
+
*/
|
|
205
|
+
const generateBaseTag = (appShellConfig) => {
|
|
206
|
+
const publicPath = getPublicPath(appShellConfig);
|
|
207
|
+
return {
|
|
208
|
+
name: "vite-plugin-generate-base",
|
|
209
|
+
enforce: "pre",
|
|
210
|
+
// except for react and react-dom when in dev mode
|
|
211
|
+
transformIndexHtml: {
|
|
212
|
+
enforce: "post",
|
|
213
|
+
transform: (html) => ({
|
|
214
|
+
html,
|
|
215
|
+
tags: [
|
|
216
|
+
{
|
|
217
|
+
tag: "base",
|
|
218
|
+
attrs: { href: publicPath },
|
|
219
|
+
injectTo: "head-prepend"
|
|
220
|
+
}
|
|
221
|
+
]
|
|
222
|
+
})
|
|
223
|
+
}
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Vite plugin to support App Shell apps setup
|
|
228
|
+
* @param opts Plugin options
|
|
229
|
+
*/
|
|
230
|
+
export function appShellVitePlugin(opts = {}) {
|
|
231
|
+
const root = opts.root || process.cwd();
|
|
232
|
+
const mode = opts.mode || ViteBuildMode.PRODUCTION;
|
|
233
|
+
console.info(`Vite running in mode: ${mode}`);
|
|
234
|
+
const devMode = mode === ViteBuildMode.DEVELOPMENT;
|
|
235
|
+
const packageJsonRaw = fs.readFileSync(path.resolve(root, "package.json"), "utf-8");
|
|
236
|
+
const packageJson = JSON.parse(packageJsonRaw);
|
|
237
|
+
const appShellConfigRaw = fs.readFileSync(path.resolve(root, "app-shell.config.json"), "utf-8");
|
|
238
|
+
const appShellConfiguration = JSON.parse(appShellConfigRaw);
|
|
239
|
+
return [
|
|
240
|
+
// Copy all the required js bundles to final "bundles" folders, that will be injected by the importmap
|
|
241
|
+
viteStaticCopy({
|
|
242
|
+
targets: [
|
|
243
|
+
{
|
|
244
|
+
src: getModulePath("es-module-shims", "dist/*"),
|
|
245
|
+
dest: "bundles"
|
|
246
|
+
},
|
|
247
|
+
...(!devMode
|
|
248
|
+
? [
|
|
249
|
+
{
|
|
250
|
+
src: [
|
|
251
|
+
resolveModule("./esm-externals/react.production.min.js"),
|
|
252
|
+
resolveModule("./esm-externals/react.production.min.js.map"),
|
|
253
|
+
resolveModule("./esm-externals/react-dom.production.min.js"),
|
|
254
|
+
resolveModule("./esm-externals/react-dom.production.min.js.map"),
|
|
255
|
+
resolveModule("./esm-externals/react-router-dom.production.min.js"),
|
|
256
|
+
resolveModule("./esm-externals/react-router-dom.production.min.js.map"),
|
|
257
|
+
resolveModule("@hitachivantara/app-shell-shared/bundles/app-shell-shared.esm.js"),
|
|
258
|
+
resolveModule("@hitachivantara/app-shell-shared/bundles/app-shell-shared.esm.js.map"),
|
|
259
|
+
resolveModule("@hitachivantara/uikit-react-shared/bundles/uikit-react-shared.esm.js"),
|
|
260
|
+
resolveModule("@hitachivantara/uikit-react-shared/bundles/uikit-react-shared.esm.js.map")
|
|
261
|
+
],
|
|
262
|
+
dest: "bundles"
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
: [])
|
|
266
|
+
]
|
|
267
|
+
}),
|
|
268
|
+
// create virtual endpoints to support dev mode
|
|
269
|
+
virtual({
|
|
270
|
+
"/bundles/react.production.min.js": `import * as React from "react";
|
|
271
|
+
export default React;
|
|
272
|
+
|
|
273
|
+
export {
|
|
274
|
+
Fragment,
|
|
275
|
+
StrictMode,
|
|
276
|
+
Profiler,
|
|
277
|
+
Suspense,
|
|
278
|
+
Children,
|
|
279
|
+
Component,
|
|
280
|
+
PureComponent,
|
|
281
|
+
cloneElement,
|
|
282
|
+
createContext,
|
|
283
|
+
createElement,
|
|
284
|
+
createFactory,
|
|
285
|
+
createRef,
|
|
286
|
+
forwardRef,
|
|
287
|
+
isValidElement,
|
|
288
|
+
lazy,
|
|
289
|
+
memo,
|
|
290
|
+
useCallback,
|
|
291
|
+
useContext,
|
|
292
|
+
useDebugValue,
|
|
293
|
+
useEffect,
|
|
294
|
+
useImperativeHandle,
|
|
295
|
+
useLayoutEffect,
|
|
296
|
+
useMemo,
|
|
297
|
+
useReducer,
|
|
298
|
+
useRef,
|
|
299
|
+
useState,
|
|
300
|
+
version,
|
|
301
|
+
} from "react";`,
|
|
302
|
+
"/bundles/react-dom.production.min.js": `export {
|
|
303
|
+
default,
|
|
304
|
+
flushSync,
|
|
305
|
+
createPortal,
|
|
306
|
+
findDOMNode,
|
|
307
|
+
hydrate,
|
|
308
|
+
render,
|
|
309
|
+
unmountComponentAtNode,
|
|
310
|
+
unstable_batchedUpdates,
|
|
311
|
+
unstable_renderSubtreeIntoContainer,
|
|
312
|
+
version,
|
|
313
|
+
} from "react-dom";`,
|
|
314
|
+
"/bundles/react-router-dom.production.min.js": `export * from "react-router-dom";`,
|
|
315
|
+
"/bundles/app-shell-shared.esm.js": `export * from "@hitachivantara/app-shell-shared";`,
|
|
316
|
+
"/bundles/uikit-react-shared.esm.js": `export * from "@hitachivantara/uikit-react-shared";`
|
|
317
|
+
}),
|
|
318
|
+
// generation of the importmap to create the link to the js bundles
|
|
319
|
+
generateImportmap({
|
|
320
|
+
react: `./bundles/react.production.min.js`,
|
|
321
|
+
"react-dom": `./bundles/react-dom.production.min.js`,
|
|
322
|
+
"react-router-dom": `./bundles/react-router-dom.production.min.js`,
|
|
323
|
+
"@hitachivantara/app-shell-shared": "./bundles/app-shell-shared.esm.js",
|
|
324
|
+
"@hitachivantara/uikit-react-shared": "./bundles/uikit-react-shared.esm.js",
|
|
325
|
+
...appShellConfiguration?.apps?.reduce((acc, app) => {
|
|
326
|
+
if (app.id === "@self") {
|
|
327
|
+
acc[`${packageJson.name}/`] = app.baseUrl;
|
|
328
|
+
if (devMode) {
|
|
329
|
+
acc[`${app.id}/`] = app.baseUrl;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
else {
|
|
333
|
+
acc[`${app.id}/`] = app.baseUrl;
|
|
334
|
+
}
|
|
335
|
+
return acc;
|
|
336
|
+
}, {})
|
|
337
|
+
}, [
|
|
338
|
+
"react",
|
|
339
|
+
"react-dom",
|
|
340
|
+
"react-router-dom",
|
|
341
|
+
"@hitachivantara/app-shell-shared",
|
|
342
|
+
"@hitachivantara/uikit-react-shared",
|
|
343
|
+
"@self",
|
|
344
|
+
packageJson.name
|
|
345
|
+
], opts.externalImportMap),
|
|
346
|
+
generateBaseTag(appShellConfiguration),
|
|
347
|
+
// process configuration
|
|
348
|
+
processConfiguration(root, appShellConfiguration, packageJson.name)
|
|
349
|
+
];
|
|
350
|
+
}
|
|
351
|
+
export default appShellVitePlugin;
|
|
352
|
+
//# sourceMappingURL=vite-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite-plugin.js","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAGzD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAK5C,OAAO,iBAAiB,MAAM,4BAA4B,CAAC;AAE3D,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C;;;GAGG;AACH,MAAM,UAAU,GAAG,CACjB,cAAgC,EACE,EAAE;IACpC,OAAO,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAC,cAAgC,EAAU,EAAE;IACjE,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,IA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B,GAAG,CAAC,GAAG,WAAW,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;oBAC1C,IAAI,OAAO,EAAE;wBACX,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;qBACjC;iBACF;qBAAM;oBACL,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;iBACjC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAA4B,CAAC;SACjC,EACD;YACE,OAAO;YACP,WAAW;YACX,kBAAkB;YAClB,kCAAkC;YAClC,oCAAoC;YACpC,OAAO;YACP,WAAW,CAAC,IAAI;SACjB,EACD,IAAI,CAAC,iBAAiB,CACvB;QACD,eAAe,CAAC,qBAAqB,CAAC;QACtC,wBAAwB;QACxB,oBAAoB,CAAC,IAAI,EAAE,qBAAqB,EAAE,WAAW,CAAC,IAAI,CAAC;KACpE,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import { NormalizedOutputOptions, OutputBundle } from \"rollup\";\nimport virtual from \"@rollup/plugin-virtual\";\n\nimport fs from \"fs\";\nimport path from \"path\";\n\nimport { viteStaticCopy } from \"vite-plugin-static-copy\";\nimport { PluginOption, UserConfig } from \"vite\";\n\nimport { createRequire } from \"node:module\";\nimport {\n HvAppShellAppsConfig,\n HvAppShellConfig\n} from \"@hitachivantara/app-shell-shared\";\nimport generateImportmap from \"./vite-importmap-plugin.js\";\n\nconst require = createRequire(import.meta.url);\n\n/**\n * Return the main app (identified by @self)\n * @param appShellConfig The App shell configuration\n */\nconst getMainApp = (\n appShellConfig: HvAppShellConfig\n): HvAppShellAppsConfig | undefined => {\n return appShellConfig.apps.filter(app => app.id === \"@self\")[0];\n};\n\n/**\n * Return the public path to be use by vite to launch the application.\n * Value is obtained by returning the baseUrl value of the main app {@link #getMainApp}\n * @param appShellConfig The App shell configuration\n */\nconst getPublicPath = (appShellConfig: HvAppShellConfig): string => {\n const mainApp = getMainApp(appShellConfig);\n if (!mainApp) {\n return \"/\";\n }\n const url = mainApp.baseUrl;\n try {\n return new URL(url).pathname;\n } catch {\n return url;\n }\n};\n\n/**\n * Resolves the module name and normalizes slashes to be posix/unix-like forward slashes.\n *\n * @param moduleName The name of the module to be searched for\n * @returns The module path normalized\n */\nfunction resolveModule(moduleName: string) {\n const module = require.resolve(moduleName);\n return module.replace(/\\\\+/g, \"/\");\n}\n\n/**\n * This function will find out the module path using node `require.resolve` function\n * and add the suffix param after the folder with module name.\n *\n * @param moduleName \"@module/name\"\n * @param suffix to be added after the module path\n * @returns the /path/to/@module/name/<suffix>\n */\nfunction getModulePath(moduleName: string, suffix: string) {\n const moduleNameWithSlashes = `/${moduleName}/`;\n const module = resolveModule(moduleName);\n const modulePosition = module.lastIndexOf(moduleNameWithSlashes);\n return `${module.slice(\n 0,\n modulePosition + moduleNameWithSlashes.length\n )}${suffix}`;\n}\n\nenum ViteBuildMode {\n PRODUCTION = \"production\",\n DEVELOPMENT = \"development\"\n}\n\nenum ViteCommand {\n BUILD = \"build\",\n SERVE = \"serve\"\n}\n\n/**\n * Returns the modules to be created by the build of the app.\n * The list of modules is defined by the app-shell-config.json file routes ( limited to the @self app)\n * The bundles will be created following the original directories structure ( having the src folder path removed)\n *\n * @param root Project root directory.\n * @param appShellConfig The App Shell configuration.\n */\nfunction getAppModules(root: string, appShellConfig: HvAppShellConfig) {\n const appModules: { [key: string]: string } = {};\n\n const selfApp = getMainApp(appShellConfig);\n const selfViews =\n selfApp?.views?.map(view => {\n const bundleName = view.bundle.replace(/^src\\//, \"\");\n return {\n ...view,\n bundleName\n };\n }) ?? [];\n\n selfViews.forEach(view => {\n appModules[view.bundleName] = path.resolve(root, view.bundle);\n });\n\n const selfModules =\n selfApp?.modules?.map(module => {\n const bundleName = module.bundle.replace(/^src\\//, \"\");\n return {\n ...module,\n bundleName\n };\n }) ?? [];\n\n selfModules.forEach(module => {\n appModules[module.bundleName] = path.resolve(root, module.bundle);\n });\n\n console.info(\"Modules exported by the application bundle:\", appModules);\n return appModules;\n}\n\n/**\n * Process configuration, executing several tasks:\n * - Create rollup configuration to support module creation\n * - Generates final transformed configuration json\n * - \"base\" value is always \"./\" for build, and main app baseUrl for preview or dev\n * - Injects the APP_BASE_PATH env prop, to be used by the apps (if required)\n * @param root Project root directory.\n * @param appShellConfig The original App Shell configuration json.\n * @param selfAppName The name of the application bundle being built.\n */\nfunction processConfiguration(\n root: string,\n appShellConfig: HvAppShellConfig,\n selfAppName: string\n): PluginOption {\n const finalAppShellConfig = { ...appShellConfig };\n const selfApp = getMainApp(finalAppShellConfig);\n\n return {\n name: \"vite-plugin-appShell-configuration-processor\",\n\n config(config: UserConfig, { command }) {\n const projectRoot = root ?? config.root;\n\n const publicPath = getPublicPath(appShellConfig);\n return {\n build: {\n rollupOptions: {\n preserveEntrySignatures: \"strict\",\n input: {\n main: path.resolve(projectRoot, \"index.html\"),\n ...getAppModules(projectRoot, appShellConfig)\n },\n output: {\n entryFileNames: \"[name].js\"\n }\n }\n },\n // if serve (preview/dev) it uses the baseUrl. Otherwise(build), use ./\n base: command === ViteCommand.SERVE ? publicPath : \"./\",\n define: {\n ...config.define,\n APP_BASE_PATH: JSON.stringify(publicPath)\n }\n };\n },\n\n /**\n * Rollup hook with the info for bundle generation\n * It will be used to create a new configuration with:\n * - bundles replace with the final location (e.g. -> \"bundle\": \"src/pages/Main\" transformed to \"bundle\": \"pages/Main.js\",\n * @param options build options\n * @param bundle bundles information\n */\n async generateBundle(\n options: NormalizedOutputOptions,\n bundle: OutputBundle\n ) {\n // obtain the directory (dist) where the new config file will be placed\n let targetDir: string | undefined;\n if (options.dir) {\n targetDir = options.dir;\n } else if (options.file) {\n targetDir = path.dirname(options.file);\n }\n\n if (!targetDir) {\n throw new Error(\n \"Please set outputPath, so we can know where to place the json file\"\n );\n }\n\n // create the targetDir if it does not exist\n if (!fs.existsSync(targetDir)) {\n fs.mkdirSync(targetDir, { recursive: true });\n }\n\n /**\n * Creating a map with each chunk and the final name. Only the bundles with type=chunck are important\n * Filename do not include the src path at the value\n */\n const chunks: Record<string, string> = {};\n\n Object.keys(bundle).forEach(key => {\n const chunk = bundle[key];\n if (chunk.type === \"chunk\") {\n const outputChunk = chunk;\n if (outputChunk.isEntry) {\n const { fileName } = outputChunk;\n const { name } = outputChunk;\n\n chunks[name] = fileName;\n }\n }\n });\n\n if (selfApp) {\n selfApp.views = selfApp.views?.map(view => {\n const bundleName = view.bundle.replace(/^src\\//, \"\");\n return {\n ...view,\n bundle: chunks[bundleName]\n };\n });\n selfApp.modules = selfApp.modules?.map(module => {\n const bundleName = module.bundle.replace(/^src\\//, \"\");\n return {\n ...module,\n bundle: chunks[bundleName]\n };\n });\n\n // replace references to @self with the name of this application bundle\n selfApp.id = selfAppName;\n }\n\n fs.writeFileSync(\n path.resolve(targetDir, \"app-shell.config.json\"),\n JSON.stringify(finalAppShellConfig)\n );\n }\n };\n}\n\n/**\n * Add the <BASE> tag at index.html file. Tag value is obtained by the main app ({@link #getMainApp}) baseUrl ({@link #getPublicPath})‘\n * @param appShellConfig The app shell configuration.\n */\nconst generateBaseTag = (appShellConfig: HvAppShellConfig): PluginOption => {\n const publicPath = getPublicPath(appShellConfig);\n return {\n name: \"vite-plugin-generate-base\",\n enforce: \"pre\",\n // except for react and react-dom when in dev mode\n transformIndexHtml: {\n enforce: \"post\",\n transform: (html: string) => ({\n html,\n tags: [\n {\n tag: \"base\",\n attrs: { href: publicPath },\n injectTo: \"head-prepend\"\n }\n ]\n })\n }\n };\n};\n\ninterface AppShellVitePluginOptions {\n /**\n * Project root directory. Most likely location of the vite config file.\n *\n * @default process.cwd()\n */\n root?: string;\n /**\n * Execution mode.\n */\n mode?: string;\n /**\n * If true, the plugin will generate the importmap with an external js file instead of inline in the html.\n * The map will be saved at the root of the application destination dir and named as \"importmap.js\"\n *\n * @default false\n */\n externalImportMap?: boolean;\n}\n\n/**\n * Vite plugin to support App Shell apps setup\n * @param opts Plugin options\n */\nexport function appShellVitePlugin(\n opts: AppShellVitePluginOptions = {}\n): PluginOption {\n const root = opts.root || process.cwd();\n const mode = opts.mode || ViteBuildMode.PRODUCTION;\n\n console.info(`Vite running in mode: ${mode}`);\n\n const devMode = mode === ViteBuildMode.DEVELOPMENT;\n\n const packageJsonRaw = fs.readFileSync(\n path.resolve(root, \"package.json\"),\n \"utf-8\"\n );\n const packageJson = JSON.parse(packageJsonRaw);\n\n const appShellConfigRaw = fs.readFileSync(\n path.resolve(root, \"app-shell.config.json\"),\n \"utf-8\"\n );\n const appShellConfiguration = JSON.parse(\n appShellConfigRaw\n ) as HvAppShellConfig;\n\n return [\n // Copy all the required js bundles to final \"bundles\" folders, that will be injected by the importmap\n viteStaticCopy({\n targets: [\n {\n src: getModulePath(\"es-module-shims\", \"dist/*\"),\n dest: \"bundles\"\n },\n ...(!devMode\n ? [\n {\n src: [\n resolveModule(\"./esm-externals/react.production.min.js\"),\n resolveModule(\"./esm-externals/react.production.min.js.map\"),\n resolveModule(\"./esm-externals/react-dom.production.min.js\"),\n resolveModule(\n \"./esm-externals/react-dom.production.min.js.map\"\n ),\n resolveModule(\n \"./esm-externals/react-router-dom.production.min.js\"\n ),\n resolveModule(\n \"./esm-externals/react-router-dom.production.min.js.map\"\n ),\n resolveModule(\n \"@hitachivantara/app-shell-shared/bundles/app-shell-shared.esm.js\"\n ),\n resolveModule(\n \"@hitachivantara/app-shell-shared/bundles/app-shell-shared.esm.js.map\"\n ),\n resolveModule(\n \"@hitachivantara/uikit-react-shared/bundles/uikit-react-shared.esm.js\"\n ),\n resolveModule(\n \"@hitachivantara/uikit-react-shared/bundles/uikit-react-shared.esm.js.map\"\n )\n ],\n dest: \"bundles\"\n }\n ]\n : [])\n ]\n }),\n\n // create virtual endpoints to support dev mode\n virtual({\n \"/bundles/react.production.min.js\": `import * as React from \"react\";\n export default React;\n\n export {\n Fragment,\n StrictMode,\n Profiler,\n Suspense,\n Children,\n Component,\n PureComponent,\n cloneElement,\n createContext,\n createElement,\n createFactory,\n createRef,\n forwardRef,\n isValidElement,\n lazy,\n memo,\n useCallback,\n useContext,\n useDebugValue,\n useEffect,\n useImperativeHandle,\n useLayoutEffect,\n useMemo,\n useReducer,\n useRef,\n useState,\n version,\n } from \"react\";`,\n \"/bundles/react-dom.production.min.js\": `export {\n default,\n flushSync,\n createPortal,\n findDOMNode,\n hydrate,\n render,\n unmountComponentAtNode,\n unstable_batchedUpdates,\n unstable_renderSubtreeIntoContainer,\n version,\n } from \"react-dom\";`,\n \"/bundles/react-router-dom.production.min.js\": `export * from \"react-router-dom\";`,\n \"/bundles/app-shell-shared.esm.js\": `export * from \"@hitachivantara/app-shell-shared\";`,\n \"/bundles/uikit-react-shared.esm.js\": `export * from \"@hitachivantara/uikit-react-shared\";`\n }),\n\n // generation of the importmap to create the link to the js bundles\n generateImportmap(\n {\n react: `./bundles/react.production.min.js`,\n \"react-dom\": `./bundles/react-dom.production.min.js`,\n \"react-router-dom\": `./bundles/react-router-dom.production.min.js`,\n \"@hitachivantara/app-shell-shared\": \"./bundles/app-shell-shared.esm.js\",\n \"@hitachivantara/uikit-react-shared\":\n \"./bundles/uikit-react-shared.esm.js\",\n ...appShellConfiguration?.apps?.reduce((acc, app) => {\n if (app.id === \"@self\") {\n acc[`${packageJson.name}/`] = app.baseUrl;\n if (devMode) {\n acc[`${app.id}/`] = app.baseUrl;\n }\n } else {\n acc[`${app.id}/`] = app.baseUrl;\n }\n return acc;\n }, {} as Record<string, string>)\n },\n [\n \"react\",\n \"react-dom\",\n \"react-router-dom\",\n \"@hitachivantara/app-shell-shared\",\n \"@hitachivantara/uikit-react-shared\",\n \"@self\",\n packageJson.name\n ],\n opts.externalImportMap\n ),\n generateBaseTag(appShellConfiguration),\n // process configuration\n processConfiguration(root, appShellConfiguration, packageJson.name)\n ];\n}\n\nexport default appShellVitePlugin;\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@hitachivantara/app-shell-vite-plugin",
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "AppShell Vite Plugin",
|
|
5
|
+
"author": "Hitachi Vantara - Boba Fett Team",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"module": "dist/index.js",
|
|
9
|
+
"main": "dist/index.js",
|
|
10
|
+
"typings": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"import": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "npm-run-all clean build:*",
|
|
26
|
+
"build:esm": "tsc -b tsconfig.json",
|
|
27
|
+
"build:esm-externals": "npx rollup --config",
|
|
28
|
+
"clean": "npx rimraf ./dist *.tgz",
|
|
29
|
+
"dev": "tsc-watch --noClear -p tsconfig.json",
|
|
30
|
+
"lint": "npm-run-all --parallel lint:*",
|
|
31
|
+
"lint:eslint": "npx eslint --ext .js,.jsx,.ts,.tsx src --color --cache --fix",
|
|
32
|
+
"lint:prettier": "npx prettier --write \"src/**/*.{html,css,js,jsx,ts,tsx}\""
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@hitachivantara/app-shell-shared": "0.5.1",
|
|
36
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
37
|
+
"@rollup/plugin-json": "^6.0.0",
|
|
38
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
39
|
+
"@rollup/plugin-replace": "^5.0.2",
|
|
40
|
+
"@rollup/plugin-terser": "^0.4.0",
|
|
41
|
+
"@rollup/plugin-virtual": "^3.0.1",
|
|
42
|
+
"es-module-shims": "^1.6.3",
|
|
43
|
+
"react": "^18.2.0",
|
|
44
|
+
"react-dom": "^18.2.0",
|
|
45
|
+
"react-router-dom": "^6.9.0",
|
|
46
|
+
"rollup": "^3.10.0",
|
|
47
|
+
"vite": "^4.1.4",
|
|
48
|
+
"vite-plugin-static-copy": "^0.13.0"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@types/react": "^18.0.28",
|
|
52
|
+
"@types/react-dom": "^18.0.11",
|
|
53
|
+
"tsc-watch": "^6.0.0"
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "904a0e52b3728c0b962acc3af79dc1ffd090836e"
|
|
56
|
+
}
|