@hitachivantara/app-shell-vite-plugin 0.10.2 → 0.11.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/dist/vite-plugin.d.ts +2 -5
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +18 -15
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +4 -4
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { PluginOption } from "vite";
|
|
2
|
-
import type { HvAppShellConfig } from "@hitachivantara/app-shell-shared";
|
|
3
|
-
type AppShellConfigFunction = (pluginOptions: AppShellVitePluginOptions) => HvAppShellConfig;
|
|
4
|
-
export declare function configAppShell(config: AppShellConfigFunction | HvAppShellConfig): HvAppShellConfig | AppShellConfigFunction;
|
|
1
|
+
import type { PluginOption } from "vite";
|
|
5
2
|
export declare enum ApplicationBundleType {
|
|
6
3
|
APP = "app",
|
|
7
4
|
BUNDLE = "bundle"
|
|
@@ -73,6 +70,6 @@ export interface AppShellVitePluginOptions {
|
|
|
73
70
|
* Vite plugin to support App Shell apps setup
|
|
74
71
|
* @param opts Plugin options
|
|
75
72
|
*/
|
|
76
|
-
export declare function appShellVitePlugin(opts?: AppShellVitePluginOptions): PluginOption;
|
|
73
|
+
export declare function appShellVitePlugin(opts?: AppShellVitePluginOptions, env?: Record<string, string>): PluginOption;
|
|
77
74
|
export default appShellVitePlugin;
|
|
78
75
|
//# sourceMappingURL=vite-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,MAAM,CAAC;AAiZrD,oBAAY,qBAAqB;IAC/B,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB;AAED,KAAK,wBAAwB,GAAG,GAAG,qBAAqB,EAAE,CAAC;AAE3D,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,wBAAwB,CAAC;IAEhC;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAExD;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AA+CD;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,GAAE,yBAA8B,EACpC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC/B,YAAY,CAqVd;AAED,eAAe,kBAAkB,CAAC"}
|
package/dist/vite-plugin.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import virtual from "@rollup/plugin-virtual";
|
|
2
1
|
import fs from "fs";
|
|
3
2
|
import path from "path";
|
|
4
|
-
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
5
|
-
import { register, createEsmHooks } from "ts-node";
|
|
6
3
|
import { createRequire } from "node:module";
|
|
4
|
+
import { register, createEsmHooks } from "ts-node";
|
|
5
|
+
import virtual from "@rollup/plugin-virtual";
|
|
6
|
+
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
7
7
|
import generateImportmap from "./vite-importmap-plugin.js";
|
|
8
8
|
createEsmHooks(register({
|
|
9
9
|
transpileOnly: true,
|
|
@@ -12,9 +12,6 @@ createEsmHooks(register({
|
|
|
12
12
|
}
|
|
13
13
|
}));
|
|
14
14
|
const require = createRequire(import.meta.url);
|
|
15
|
-
export function configAppShell(config) {
|
|
16
|
-
return config;
|
|
17
|
-
}
|
|
18
15
|
/**
|
|
19
16
|
* Return the main app (identified by @self)
|
|
20
17
|
* @param appShellConfig The App shell configuration
|
|
@@ -81,6 +78,7 @@ var ViteCommand;
|
|
|
81
78
|
*
|
|
82
79
|
* @param root Project root directory.
|
|
83
80
|
* @param appShellConfig The App Shell configuration.
|
|
81
|
+
* @param selfAppName The name of the application bundle being built.
|
|
84
82
|
*/
|
|
85
83
|
function getAppModules(root, appShellConfig, selfAppName) {
|
|
86
84
|
const appModules = {};
|
|
@@ -249,7 +247,10 @@ function processConfiguration(root, appShellConfig, selfAppName, buildEntryPoint
|
|
|
249
247
|
}
|
|
250
248
|
const finalAppShellConfig = buildEntryPoint
|
|
251
249
|
? { ...appShellConfig }
|
|
252
|
-
: {
|
|
250
|
+
: {
|
|
251
|
+
name: appShellConfig.name,
|
|
252
|
+
apps: selfApp != null ? [selfApp] : undefined
|
|
253
|
+
};
|
|
253
254
|
fs.writeFileSync(path.resolve(targetDir, "app-shell.config.json"), JSON.stringify(finalAppShellConfig));
|
|
254
255
|
}
|
|
255
256
|
};
|
|
@@ -286,13 +287,17 @@ function serveAppShellConfig(appShellConfig, root, appShellConfigFile, automatic
|
|
|
286
287
|
if (appShellConfigFile != null && file.endsWith(appShellConfigFile)) {
|
|
287
288
|
console.info("App Shell configuration file changed. Reloading...");
|
|
288
289
|
delete require.cache[require.resolve(path.resolve(root, appShellConfigFile))];
|
|
289
|
-
server
|
|
290
|
+
server
|
|
291
|
+
.restart()
|
|
292
|
+
.catch(e => console.error(`Restart failed with: ${e}`));
|
|
290
293
|
}
|
|
291
294
|
};
|
|
292
295
|
const restartServer2 = (file) => {
|
|
293
296
|
if (automaticViewsFolder != null && file.match(/\/index\.[tj]sx?$/)) {
|
|
294
297
|
console.info("Automatic views folder changed. Reloading...");
|
|
295
|
-
server
|
|
298
|
+
server
|
|
299
|
+
.restart()
|
|
300
|
+
.catch(e => console.error(`Restart failed with: ${e}`));
|
|
296
301
|
}
|
|
297
302
|
};
|
|
298
303
|
if (appShellConfigFile != null) {
|
|
@@ -352,7 +357,7 @@ function mapIndexFilesToRoutes(files, folder) {
|
|
|
352
357
|
* Vite plugin to support App Shell apps setup
|
|
353
358
|
* @param opts Plugin options
|
|
354
359
|
*/
|
|
355
|
-
export function appShellVitePlugin(opts = {}) {
|
|
360
|
+
export function appShellVitePlugin(opts = {}, env = {}) {
|
|
356
361
|
const { root = process.cwd(), mode = ViteBuildMode.PRODUCTION, externalImportMap = false, type = ApplicationBundleType.APP, viewsFolder = "src/pages", autoViewsAndRoutes = false, autoDevMenu = false } = opts;
|
|
357
362
|
const buildEntryPoint = type !== ApplicationBundleType.BUNDLE;
|
|
358
363
|
console.info(`Vite running in mode: ${mode}`);
|
|
@@ -371,11 +376,11 @@ export function appShellVitePlugin(opts = {}) {
|
|
|
371
376
|
appShellConfiguration = JSON.parse(appShellConfigRaw);
|
|
372
377
|
}
|
|
373
378
|
else {
|
|
374
|
-
// using require instead of import to
|
|
379
|
+
// using require instead of import to avoid using --experimental-loader ts-node/esm
|
|
375
380
|
// eslint-disable-next-line import/no-dynamic-require
|
|
376
381
|
const loadedAppShellConfig = require(path.resolve(root, appShellConfigFile)).default;
|
|
377
382
|
if (typeof loadedAppShellConfig === "function") {
|
|
378
|
-
appShellConfiguration = loadedAppShellConfig(opts);
|
|
383
|
+
appShellConfiguration = loadedAppShellConfig(opts, env);
|
|
379
384
|
}
|
|
380
385
|
else {
|
|
381
386
|
appShellConfiguration = loadedAppShellConfig;
|
|
@@ -420,9 +425,7 @@ export function appShellVitePlugin(opts = {}) {
|
|
|
420
425
|
if (devMode && autoDevMenu) {
|
|
421
426
|
if (appShellConfiguration.menu == null ||
|
|
422
427
|
appShellConfiguration.menu.length === 0) {
|
|
423
|
-
if (selfApp != null &&
|
|
424
|
-
selfApp.views != null &&
|
|
425
|
-
selfApp.views.length > 0) {
|
|
428
|
+
if (selfApp?.views != null && selfApp.views.length > 0) {
|
|
426
429
|
const menu = [];
|
|
427
430
|
for (let i = 0; i !== selfApp.views.length; i += 1) {
|
|
428
431
|
const view = selfApp.views[i];
|
package/dist/vite-plugin.js.map
CHANGED
|
@@ -1 +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,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQ5C,OAAO,iBAAiB,MAAM,4BAA4B,CAAC;AAE3D,cAAc,CACZ,QAAQ,CAAC;IACP,aAAa,EAAE,IAAI;IACnB,WAAW,EAAE;QACX,qBAAqB,EAAE,KAAK;KAC7B;CACF,CAAC,CACH,CAAC;AACF,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAM/C,MAAM,UAAU,cAAc,CAC5B,MAAiD;IAEjD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,GAAG,CACjB,cAAgC,EACE,EAAE;IACpC,OAAO,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAC,cAAgC,EAAU,EAAE;IACjE,MAAM,OAAO,GAAG,UAAU,C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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,gBAAgB;YAChB,gBAAgB;YAChB,OAAO;YACP,WAAW,CAAC,IAAI;SACjB,EACD,iBAAiB,IAAI,eAAe,CACrC;QACD,eAAe,IAAI,eAAe,CAAC,qBAAqB,CAAC;QACzD,wBAAwB;QACxB,oBAAoB,CAClB,IAAI,EACJ,qBAAqB,EACrB,WAAW,CAAC,IAAI,EAChB,eAAe,CAChB;QACD,mBAAmB,CACjB,qBAAqB,EACrB,IAAI,EACJ,kBAAkB,EAClB,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAC7C;KACF,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 { register, createEsmHooks } from \"ts-node\";\nimport { createRequire } from \"node:module\";\n\nimport type {\n HvAppShellAppsConfig,\n HvAppShellConfig,\n HvAppShellViewsConfig\n} from \"@hitachivantara/app-shell-shared\";\n\nimport generateImportmap from \"./vite-importmap-plugin.js\";\n\ncreateEsmHooks(\n register({\n transpileOnly: true,\n moduleTypes: {\n \"app-shell.config.ts\": \"cjs\"\n }\n })\n);\nconst require = createRequire(import.meta.url);\n\ntype AppShellConfigFunction = (\n pluginOptions: AppShellVitePluginOptions\n) => HvAppShellConfig;\n\nexport function configAppShell(\n config: AppShellConfigFunction | HvAppShellConfig\n) {\n return config;\n}\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(\n root: string,\n appShellConfig: HvAppShellConfig,\n selfAppName: string\n) {\n const appModules: { [key: string]: string } = {};\n\n const selfApp = getMainApp(appShellConfig);\n if (selfApp != null) {\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\n const implicitThemeModules =\n appShellConfig?.theming?.themes?.map(theme => {\n if (\n theme.startsWith(\"/src/\") ||\n theme.startsWith(\"@self/\") ||\n theme.startsWith(selfAppName)\n ) {\n const bundle = theme\n .replace(/^@self\\//, \"\")\n .replace(new RegExp(`^${selfAppName}/`), \"\");\n const bundleName = bundle.replace(/^(\\/?)src\\//, \"\");\n return {\n bundle,\n bundleName\n };\n }\n\n return undefined;\n }) ?? [];\n\n implicitThemeModules.forEach(module => {\n if (module != null && appModules[module.bundleName] == null) {\n appModules[module.bundleName] = path.resolve(root, module.bundle);\n }\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 * @param buildEntryPoint If true, the index.html entry point will be added to the bundle.\n */\nfunction processConfiguration(\n root: string,\n appShellConfig: HvAppShellConfig,\n selfAppName: string,\n buildEntryPoint: boolean\n): PluginOption {\n const selfApp = getMainApp(appShellConfig);\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 ...(buildEntryPoint &&\n fs.existsSync(path.resolve(projectRoot, \"index.html\"))\n ? { main: path.resolve(projectRoot, \"index.html\") }\n : {}),\n ...getAppModules(projectRoot, appShellConfig, selfAppName)\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\n .replace(/^src\\//, \"\")\n .replaceAll(/\\$/g, \"_\");\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 // also replace implicit references to selfApp in other parts of the configuration\n const { theming } = appShellConfig;\n if (theming != null) {\n theming.themes = theming.themes?.map(theme => {\n if (\n theme.startsWith(\"@self/\") ||\n theme.startsWith(selfAppName) ||\n theme.startsWith(\"/src/\")\n ) {\n const bundleName = theme\n .replace(/^@self\\//, \"\")\n .replace(new RegExp(`^${selfAppName}/`), \"\")\n .replace(/^(\\/?)src\\//, \"\");\n return `${selfAppName}/${chunks[bundleName]}`;\n }\n\n return theme;\n });\n }\n }\n\n const finalAppShellConfig = buildEntryPoint\n ? { ...appShellConfig }\n : { name: appShellConfig.name, apps: [selfApp] };\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 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\nfunction serveAppShellConfig(\n appShellConfig: HvAppShellConfig,\n root: string,\n appShellConfigFile?: string,\n automaticViewsFolder?: string\n): PluginOption {\n return {\n name: \"vite-plugin-watch-app-shell-config\",\n configureServer(server) {\n const restartServer = (file: string) => {\n if (appShellConfigFile != null && file.endsWith(appShellConfigFile)) {\n console.info(\"App Shell configuration file changed. Reloading...\");\n delete require.cache[\n require.resolve(path.resolve(root, appShellConfigFile))\n ];\n server.restart();\n }\n };\n\n const restartServer2 = (file: string) => {\n if (automaticViewsFolder != null && file.match(/\\/index\\.[tj]sx?$/)) {\n console.info(\"Automatic views folder changed. Reloading...\");\n server.restart();\n }\n };\n\n if (appShellConfigFile != null) {\n server.watcher.add(path.resolve(root, appShellConfigFile));\n server.watcher.on(\"change\", restartServer);\n }\n\n if (automaticViewsFolder != null) {\n server.watcher.add(path.resolve(root, automaticViewsFolder));\n server.watcher.on(\"unlink\", restartServer2);\n server.watcher.on(\"add\", restartServer2);\n }\n\n const publicPath = getPublicPath(appShellConfig);\n server.middlewares.use(\n `${publicPath}app-shell.config.json`,\n async (req, res) => {\n res.end(JSON.stringify(appShellConfig));\n }\n );\n }\n };\n}\n\nexport enum ApplicationBundleType {\n APP = \"app\",\n BUNDLE = \"bundle\"\n}\n\ntype ApplicationBundleTypeKey = `${ApplicationBundleType}`;\n\nexport interface 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 * Type of application bundle being built. Can be \"app\" or \"bundle\".\n *\n * - \"app\": The application bundle includes both the index.html entry point and the exported modules.\n * - \"bundle\": The application bundle will not include the index.html entry point.\n *\n * @default \"app\"\n */\n type?: ApplicationBundleTypeKey;\n\n /** Array of tokens that are replaced at app-shell.config.json during the build of the solution.\n * e.g.\n * {\n * token: \"USER_NOTIFICATIONS_URL\",\n * value: \"http://localhost:8080\"\n * }\n * Tokens used at config file must be wrapped (at the beginning and at the end) by @@ sequence\n * e.g.\n * {\n * \"id\": \"@hv/user-notifications-client\",\n * \"baseUrl\": \"@@USER_NOTIFICATIONS_URL@@\"\n * }\n */\n configReplacements?: [{ token: string; value: string }];\n\n /**\n * The folder containing Views to be shared as Shared Modules. Defaults to \"src/pages\".\n *\n * The folder path must be relative to the project root (e.g. \"src/pages\").\n */\n viewsFolder?: string;\n /**\n * If set, the plugin will search for Views at the folder specified by `viewsFolder` and will add them to the App Shell configuration as views.\n * The views' modules will be exported accordingly, and a route will be created from the folder structure.\n * Dynamic route parameters are supported by prefixing the folder name with a $ (e.g. \"src/pages/List/$id/index.tsx\" will be configured as \"/list/:id\").\n */\n autoViewsAndRoutes?: boolean;\n /**\n * If true, the plugin will try to automatically add the views to the menu.\n * This this only valid when running in dev mode and if the app-shell.config.json file does not contain any menu configuration already.\n */\n autoDevMenu?: boolean;\n}\n\nconst DEFAULT_CONFIG_FILES = [\n \"app-shell.config.ts\",\n \"app-shell.config.js\",\n \"app-shell.config.json\"\n];\n\nfunction findIndexFiles(dir: string): string[] {\n const files: string[] = [];\n\n fs.readdirSync(dir).forEach(file => {\n const filePath = path.join(dir, file);\n const stat = fs.statSync(filePath);\n\n if (stat.isDirectory()) {\n files.push(...findIndexFiles(filePath));\n } else if (file.match(/^index\\.[tj]sx?$/)) {\n files.push(filePath);\n }\n });\n\n return files;\n}\n\nfunction mapIndexFilesToRoutes(\n files: string[],\n folder: string\n): HvAppShellViewsConfig[] {\n const routes: HvAppShellViewsConfig[] = [];\n\n files.forEach(filePath => {\n const bundle = filePath.substring(\n filePath.lastIndexOf(`/${folder.replace(/^\\/|\\/$/g, \"\")}/`) + 1,\n filePath.lastIndexOf(\"/\")\n );\n const route = bundle\n .replace(new RegExp(`^${folder}`), \"\")\n .replace(/index\\.[t|j]sx?$/, \"\")\n .replaceAll(/\\$/g, \":\")\n .toLowerCase();\n routes.push({ bundle, route });\n });\n\n return routes;\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 {\n root = process.cwd(),\n mode = ViteBuildMode.PRODUCTION,\n externalImportMap = false,\n type = ApplicationBundleType.APP,\n viewsFolder = \"src/pages\",\n autoViewsAndRoutes = false,\n autoDevMenu = false\n } = opts;\n\n const buildEntryPoint = type !== ApplicationBundleType.BUNDLE;\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 appShellConfigFile: string | undefined = DEFAULT_CONFIG_FILES.find(\n file => fs.existsSync(path.resolve(root, file))\n );\n\n let appShellConfiguration: HvAppShellConfig;\n if (appShellConfigFile) {\n if (appShellConfigFile.endsWith(\".json\")) {\n // token replacement is only supported for json files\n let appShellConfigRaw = fs.readFileSync(\n path.resolve(root, \"app-shell.config.json\"),\n \"utf-8\"\n );\n\n opts.configReplacements?.forEach(item => {\n appShellConfigRaw = appShellConfigRaw.replaceAll(\n `@@${item.token}@@`,\n item.value\n );\n });\n\n appShellConfiguration = JSON.parse(appShellConfigRaw) as HvAppShellConfig;\n } else {\n // using require instead of import to avoids using --experimental-loader ts-node/esm\n // eslint-disable-next-line import/no-dynamic-require\n const loadedAppShellConfig = require(path.resolve(\n root,\n appShellConfigFile\n )).default as AppShellConfigFunction | HvAppShellConfig;\n\n if (typeof loadedAppShellConfig === \"function\") {\n appShellConfiguration = loadedAppShellConfig(opts);\n } else {\n appShellConfiguration = loadedAppShellConfig;\n }\n }\n } else {\n // an empty configuration is actually valid\n // and with the automatic views option, it can even make sense\n appShellConfiguration = {};\n }\n\n let selfApp = getMainApp(appShellConfiguration);\n if (autoViewsAndRoutes != null) {\n const folder = path.resolve(root, viewsFolder);\n if (fs.existsSync(folder)) {\n const views = mapIndexFilesToRoutes(findIndexFiles(folder), viewsFolder);\n\n if (views.length > 0) {\n if (selfApp == null) {\n selfApp = {\n id: \"@self\",\n baseUrl: \"/\"\n };\n if (appShellConfiguration.apps == null) {\n appShellConfiguration.apps = [];\n }\n appShellConfiguration.apps.push(selfApp);\n }\n\n if (selfApp.views != null && selfApp.views.length > 0) {\n const nowOverlappingViews = views.filter(view => {\n const exists = selfApp!.views!.some(\n existingView =>\n existingView.bundle === view.bundle ||\n existingView.route === view.route\n );\n return !exists;\n });\n\n selfApp.views.push(...nowOverlappingViews);\n } else {\n selfApp.views = views;\n }\n }\n }\n }\n\n if (devMode && autoDevMenu) {\n if (\n appShellConfiguration.menu == null ||\n appShellConfiguration.menu.length === 0\n ) {\n if (\n selfApp != null &&\n selfApp.views != null &&\n selfApp.views.length > 0\n ) {\n const menu: HvAppShellConfig[\"menu\"] = [];\n for (let i = 0; i !== selfApp.views.length; i += 1) {\n const view = selfApp.views[i];\n\n // skip dynamic routes (e.g. /list/:id))\n if (view.route.indexOf(\":\") === -1) {\n let currentMenu = menu;\n const bundleParts = view.bundle.split(\"/\");\n const numberOfParts = view.route\n .split(\"/\")\n .filter(part => part !== \"\").length;\n const srcFolderParts = bundleParts.length - numberOfParts;\n if (bundleParts.length > srcFolderParts) {\n for (\n let j = srcFolderParts;\n j !== bundleParts.length - 1;\n j += 1\n ) {\n const part = bundleParts[j];\n let submenu = currentMenu.find(item => item.label === part);\n if (submenu == null) {\n submenu = {\n label: part,\n submenus: []\n };\n currentMenu.push(submenu);\n }\n currentMenu = submenu.submenus!;\n }\n\n const label = bundleParts[bundleParts.length - 1];\n let menuitem = currentMenu.find(item => item.label === label);\n if (menuitem == null) {\n menuitem = {\n label\n };\n currentMenu.push(menuitem);\n }\n menuitem.target = view.route;\n }\n }\n }\n\n appShellConfiguration.menu = menu;\n }\n }\n }\n\n return [\n // Copy all the required js bundles to final \"bundles\" folders, that will be injected by the importmap\n (buildEntryPoint || devMode) &&\n viteStaticCopy({\n targets: [\n {\n src: getModulePath(\"es-module-shims\", \"dist/*\"),\n dest: \"bundles\"\n },\n ...(!devMode && buildEntryPoint\n ? [\n {\n src: [\n resolveModule(\"./esm-externals/react.production.min.js\"),\n resolveModule(\n \"./esm-externals/react.production.min.js.map\"\n ),\n resolveModule(\n \"./esm-externals/react-dom.production.min.js\"\n ),\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 \"./esm-externals/emotion-react.production.min.js\"\n ),\n resolveModule(\n \"./esm-externals/emotion-react.production.min.js.map\"\n ),\n resolveModule(\n \"./esm-externals/emotion-cache.production.min.js\"\n ),\n resolveModule(\n \"./esm-externals/emotion-cache.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 \"/virtual/main.tsx\": `import React, { Suspense } from \"react\";\n import ReactDOM from \"react-dom/client\";\n import App from \"virtual:App.tsx\";\n \n const root = ReactDOM.createRoot(document.getElementById(\"hv-root\"));\n \n root.render(React.createElement(\n Suspense,\n { fallback: true },\n React.createElement(App, null)\n ));`,\n \"virtual:App.tsx\": `import React from \"react\";\n import { HvAppShell } from \"@hitachivantara/app-shell\";\n\n const App = () => {\n return React.createElement(HvAppShell, {\n configUrl: window.location.origin + APP_BASE_PATH + \"app-shell.config.json\"\n });\n };\n \n export default App;`,\n\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/emotion-react.production.min.js\": `export * from \"@emotion/react\";`,\n \"/bundles/emotion-cache.production.min.js\": `import createCache from \"@emotion/cache\"; export default createCache;`,\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 \"@emotion/react\": \"./bundles/emotion-react.production.min.js\",\n \"@emotion/cache\": \"./bundles/emotion-cache.production.min.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 \"@emotion/react\",\n \"@emotion/cache\",\n \"@self\",\n packageJson.name\n ],\n externalImportMap && buildEntryPoint\n ),\n buildEntryPoint && generateBaseTag(appShellConfiguration),\n // process configuration\n processConfiguration(\n root,\n appShellConfiguration,\n packageJson.name,\n buildEntryPoint\n ),\n serveAppShellConfig(\n appShellConfiguration,\n root,\n appShellConfigFile,\n autoViewsAndRoutes ? viewsFolder : undefined\n )\n ];\n}\n\nexport default appShellVitePlugin;\n"]}
|
|
1
|
+
{"version":3,"file":"vite-plugin.js","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAWzD,OAAO,iBAAiB,MAAM,4BAA4B,CAAC;AAE3D,cAAc,CACZ,QAAQ,CAAC;IACP,aAAa,EAAE,IAAI;IACnB,WAAW,EAAE;QACX,qBAAqB,EAAE,KAAK;KAC7B;CACF,CAAC,CACH,CAAC;AACF,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAO/C;;;GAGG;AACH,MAAM,UAAU,GAAG,CACjB,cAAgC,EACE,EAAE;IACpC,OAAO,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;AACnE,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,aAAa,GAAG,CAAC,cAAgC,EAAU,EAAE;IACjE,MAAM,OAAO,GAAG,UAAU,CAAC,cAAc,CAAC,CAAC;IAC3C,IAAI,CAAC,OAAO,EAAE;QACZ,OAAO,GAAG,CAAC;KACZ;IACD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC;IAC5B,IAAI;QACF,OAAO,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC;KAC9B;IAAC,MAAM;QACN,OAAO,GAAG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,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,gBAAgB;YAChB,gBAAgB;YAChB,OAAO;YACP,WAAW,CAAC,IAAI;SACjB,EACD,iBAAiB,IAAI,eAAe,CACrC;QACD,eAAe,IAAI,eAAe,CAAC,qBAAqB,CAAC;QACzD,wBAAwB;QACxB,oBAAoB,CAClB,IAAI,EACJ,qBAAqB,EACrB,WAAW,CAAC,IAAI,EAChB,eAAe,CAChB;QACD,mBAAmB,CACjB,qBAAqB,EACrB,IAAI,EACJ,kBAAkB,EAClB,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAC7C;KACF,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\nimport { createRequire } from \"node:module\";\nimport { register, createEsmHooks } from \"ts-node\";\n\nimport virtual from \"@rollup/plugin-virtual\";\nimport { viteStaticCopy } from \"vite-plugin-static-copy\";\n\nimport type { NormalizedOutputOptions, OutputBundle } from \"rollup\";\nimport type { PluginOption, UserConfig } from \"vite\";\n\nimport type {\n HvAppShellAppsConfig,\n HvAppShellConfig,\n HvAppShellViewsConfig\n} from \"@hitachivantara/app-shell-shared\";\n\nimport generateImportmap from \"./vite-importmap-plugin.js\";\n\ncreateEsmHooks(\n register({\n transpileOnly: true,\n moduleTypes: {\n \"app-shell.config.ts\": \"cjs\"\n }\n })\n);\nconst require = createRequire(import.meta.url);\n\ntype AppShellConfigFunction = (\n pluginOptions: AppShellVitePluginOptions,\n env: Record<string, string>\n) => HvAppShellConfig;\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 * @param selfAppName The name of the application bundle being built.\n */\nfunction getAppModules(\n root: string,\n appShellConfig: HvAppShellConfig,\n selfAppName: string\n) {\n const appModules: { [key: string]: string } = {};\n\n const selfApp = getMainApp(appShellConfig);\n if (selfApp != null) {\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\n const implicitThemeModules =\n appShellConfig?.theming?.themes?.map(theme => {\n if (\n theme.startsWith(\"/src/\") ||\n theme.startsWith(\"@self/\") ||\n theme.startsWith(selfAppName)\n ) {\n const bundle = theme\n .replace(/^@self\\//, \"\")\n .replace(new RegExp(`^${selfAppName}/`), \"\");\n const bundleName = bundle.replace(/^(\\/?)src\\//, \"\");\n return {\n bundle,\n bundleName\n };\n }\n\n return undefined;\n }) ?? [];\n\n implicitThemeModules.forEach(module => {\n if (module != null && appModules[module.bundleName] == null) {\n appModules[module.bundleName] = path.resolve(root, module.bundle);\n }\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 * @param buildEntryPoint If true, the index.html entry point will be added to the bundle.\n */\nfunction processConfiguration(\n root: string,\n appShellConfig: HvAppShellConfig,\n selfAppName: string,\n buildEntryPoint: boolean\n): PluginOption {\n const selfApp = getMainApp(appShellConfig);\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 ...(buildEntryPoint &&\n fs.existsSync(path.resolve(projectRoot, \"index.html\"))\n ? { main: path.resolve(projectRoot, \"index.html\") }\n : {}),\n ...getAppModules(projectRoot, appShellConfig, selfAppName)\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\n .replace(/^src\\//, \"\")\n .replaceAll(/\\$/g, \"_\");\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 // also replace implicit references to selfApp in other parts of the configuration\n const { theming } = appShellConfig;\n if (theming != null) {\n theming.themes = theming.themes?.map(theme => {\n if (\n theme.startsWith(\"@self/\") ||\n theme.startsWith(selfAppName) ||\n theme.startsWith(\"/src/\")\n ) {\n const bundleName = theme\n .replace(/^@self\\//, \"\")\n .replace(new RegExp(`^${selfAppName}/`), \"\")\n .replace(/^(\\/?)src\\//, \"\");\n return `${selfAppName}/${chunks[bundleName]}`;\n }\n\n return theme;\n });\n }\n }\n\n const finalAppShellConfig = buildEntryPoint\n ? { ...appShellConfig }\n : {\n name: appShellConfig.name,\n apps: selfApp != null ? [selfApp] : undefined\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 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\nfunction serveAppShellConfig(\n appShellConfig: HvAppShellConfig,\n root: string,\n appShellConfigFile?: string,\n automaticViewsFolder?: string\n): PluginOption {\n return {\n name: \"vite-plugin-watch-app-shell-config\",\n configureServer(server) {\n const restartServer = (file: string) => {\n if (appShellConfigFile != null && file.endsWith(appShellConfigFile)) {\n console.info(\"App Shell configuration file changed. Reloading...\");\n delete require.cache[\n require.resolve(path.resolve(root, appShellConfigFile))\n ];\n server\n .restart()\n .catch(e => console.error(`Restart failed with: ${e}`));\n }\n };\n\n const restartServer2 = (file: string) => {\n if (automaticViewsFolder != null && file.match(/\\/index\\.[tj]sx?$/)) {\n console.info(\"Automatic views folder changed. Reloading...\");\n server\n .restart()\n .catch(e => console.error(`Restart failed with: ${e}`));\n }\n };\n\n if (appShellConfigFile != null) {\n server.watcher.add(path.resolve(root, appShellConfigFile));\n server.watcher.on(\"change\", restartServer);\n }\n\n if (automaticViewsFolder != null) {\n server.watcher.add(path.resolve(root, automaticViewsFolder));\n server.watcher.on(\"unlink\", restartServer2);\n server.watcher.on(\"add\", restartServer2);\n }\n\n const publicPath = getPublicPath(appShellConfig);\n server.middlewares.use(\n `${publicPath}app-shell.config.json`,\n async (req, res) => {\n res.end(JSON.stringify(appShellConfig));\n }\n );\n }\n };\n}\n\nexport enum ApplicationBundleType {\n APP = \"app\",\n BUNDLE = \"bundle\"\n}\n\ntype ApplicationBundleTypeKey = `${ApplicationBundleType}`;\n\nexport interface 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 * Type of application bundle being built. Can be \"app\" or \"bundle\".\n *\n * - \"app\": The application bundle includes both the index.html entry point and the exported modules.\n * - \"bundle\": The application bundle will not include the index.html entry point.\n *\n * @default \"app\"\n */\n type?: ApplicationBundleTypeKey;\n\n /** Array of tokens that are replaced at app-shell.config.json during the build of the solution.\n * e.g.\n * {\n * token: \"USER_NOTIFICATIONS_URL\",\n * value: \"http://localhost:8080\"\n * }\n * Tokens used at config file must be wrapped (at the beginning and at the end) by @@ sequence\n * e.g.\n * {\n * \"id\": \"@hv/user-notifications-client\",\n * \"baseUrl\": \"@@USER_NOTIFICATIONS_URL@@\"\n * }\n */\n configReplacements?: [{ token: string; value: string }];\n\n /**\n * The folder containing Views to be shared as Shared Modules. Defaults to \"src/pages\".\n *\n * The folder path must be relative to the project root (e.g. \"src/pages\").\n */\n viewsFolder?: string;\n /**\n * If set, the plugin will search for Views at the folder specified by `viewsFolder` and will add them to the App Shell configuration as views.\n * The views' modules will be exported accordingly, and a route will be created from the folder structure.\n * Dynamic route parameters are supported by prefixing the folder name with a $ (e.g. \"src/pages/List/$id/index.tsx\" will be configured as \"/list/:id\").\n */\n autoViewsAndRoutes?: boolean;\n /**\n * If true, the plugin will try to automatically add the views to the menu.\n * This this only valid when running in dev mode and if the app-shell.config.json file does not contain any menu configuration already.\n */\n autoDevMenu?: boolean;\n}\n\nconst DEFAULT_CONFIG_FILES = [\n \"app-shell.config.ts\",\n \"app-shell.config.js\",\n \"app-shell.config.json\"\n];\n\nfunction findIndexFiles(dir: string): string[] {\n const files: string[] = [];\n\n fs.readdirSync(dir).forEach(file => {\n const filePath = path.join(dir, file);\n const stat = fs.statSync(filePath);\n\n if (stat.isDirectory()) {\n files.push(...findIndexFiles(filePath));\n } else if (file.match(/^index\\.[tj]sx?$/)) {\n files.push(filePath);\n }\n });\n\n return files;\n}\n\nfunction mapIndexFilesToRoutes(\n files: string[],\n folder: string\n): HvAppShellViewsConfig[] {\n const routes: HvAppShellViewsConfig[] = [];\n\n files.forEach(filePath => {\n const bundle = filePath.substring(\n filePath.lastIndexOf(`/${folder.replace(/^\\/|\\/$/g, \"\")}/`) + 1,\n filePath.lastIndexOf(\"/\")\n );\n const route = bundle\n .replace(new RegExp(`^${folder}`), \"\")\n .replace(/index\\.[t|j]sx?$/, \"\")\n .replaceAll(/\\$/g, \":\")\n .toLowerCase();\n routes.push({ bundle, route });\n });\n\n return routes;\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 env: Record<string, string> = {}\n): PluginOption {\n const {\n root = process.cwd(),\n mode = ViteBuildMode.PRODUCTION,\n externalImportMap = false,\n type = ApplicationBundleType.APP,\n viewsFolder = \"src/pages\",\n autoViewsAndRoutes = false,\n autoDevMenu = false\n } = opts;\n\n const buildEntryPoint = type !== ApplicationBundleType.BUNDLE;\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 appShellConfigFile: string | undefined = DEFAULT_CONFIG_FILES.find(\n file => fs.existsSync(path.resolve(root, file))\n );\n\n let appShellConfiguration: HvAppShellConfig;\n if (appShellConfigFile) {\n if (appShellConfigFile.endsWith(\".json\")) {\n // token replacement is only supported for json files\n let appShellConfigRaw = fs.readFileSync(\n path.resolve(root, \"app-shell.config.json\"),\n \"utf-8\"\n );\n\n opts.configReplacements?.forEach(item => {\n appShellConfigRaw = appShellConfigRaw.replaceAll(\n `@@${item.token}@@`,\n item.value\n );\n });\n\n appShellConfiguration = JSON.parse(appShellConfigRaw) as HvAppShellConfig;\n } else {\n // using require instead of import to avoid using --experimental-loader ts-node/esm\n // eslint-disable-next-line import/no-dynamic-require\n const loadedAppShellConfig = require(path.resolve(\n root,\n appShellConfigFile\n )).default as AppShellConfigFunction | HvAppShellConfig;\n\n if (typeof loadedAppShellConfig === \"function\") {\n appShellConfiguration = loadedAppShellConfig(opts, env);\n } else {\n appShellConfiguration = loadedAppShellConfig;\n }\n }\n } else {\n // an empty configuration is actually valid\n // and with the automatic views option, it can even make sense\n appShellConfiguration = {};\n }\n\n let selfApp = getMainApp(appShellConfiguration);\n if (autoViewsAndRoutes != null) {\n const folder = path.resolve(root, viewsFolder);\n if (fs.existsSync(folder)) {\n const views = mapIndexFilesToRoutes(findIndexFiles(folder), viewsFolder);\n\n if (views.length > 0) {\n if (selfApp == null) {\n selfApp = {\n id: \"@self\",\n baseUrl: \"/\"\n };\n if (appShellConfiguration.apps == null) {\n appShellConfiguration.apps = [];\n }\n appShellConfiguration.apps.push(selfApp);\n }\n\n if (selfApp.views != null && selfApp.views.length > 0) {\n const nowOverlappingViews = views.filter(view => {\n const exists = selfApp!.views!.some(\n existingView =>\n existingView.bundle === view.bundle ||\n existingView.route === view.route\n );\n return !exists;\n });\n\n selfApp.views.push(...nowOverlappingViews);\n } else {\n selfApp.views = views;\n }\n }\n }\n }\n\n if (devMode && autoDevMenu) {\n if (\n appShellConfiguration.menu == null ||\n appShellConfiguration.menu.length === 0\n ) {\n if (selfApp?.views != null && selfApp.views.length > 0) {\n const menu: HvAppShellConfig[\"menu\"] = [];\n for (let i = 0; i !== selfApp.views.length; i += 1) {\n const view = selfApp.views[i];\n\n // skip dynamic routes (e.g. /list/:id))\n if (view.route.indexOf(\":\") === -1) {\n let currentMenu = menu;\n const bundleParts = view.bundle.split(\"/\");\n const numberOfParts = view.route\n .split(\"/\")\n .filter(part => part !== \"\").length;\n const srcFolderParts = bundleParts.length - numberOfParts;\n if (bundleParts.length > srcFolderParts) {\n for (\n let j = srcFolderParts;\n j !== bundleParts.length - 1;\n j += 1\n ) {\n const part = bundleParts[j];\n let submenu = currentMenu.find(item => item.label === part);\n if (submenu == null) {\n submenu = {\n label: part,\n submenus: []\n };\n currentMenu.push(submenu);\n }\n currentMenu = submenu.submenus!;\n }\n\n const label = bundleParts[bundleParts.length - 1];\n let menuitem = currentMenu.find(item => item.label === label);\n if (menuitem == null) {\n menuitem = {\n label\n };\n currentMenu.push(menuitem);\n }\n menuitem.target = view.route;\n }\n }\n }\n\n appShellConfiguration.menu = menu;\n }\n }\n }\n\n return [\n // Copy all the required js bundles to final \"bundles\" folders, that will be injected by the importmap\n (buildEntryPoint || devMode) &&\n viteStaticCopy({\n targets: [\n {\n src: getModulePath(\"es-module-shims\", \"dist/*\"),\n dest: \"bundles\"\n },\n ...(!devMode && buildEntryPoint\n ? [\n {\n src: [\n resolveModule(\"./esm-externals/react.production.min.js\"),\n resolveModule(\n \"./esm-externals/react.production.min.js.map\"\n ),\n resolveModule(\n \"./esm-externals/react-dom.production.min.js\"\n ),\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 \"./esm-externals/emotion-react.production.min.js\"\n ),\n resolveModule(\n \"./esm-externals/emotion-react.production.min.js.map\"\n ),\n resolveModule(\n \"./esm-externals/emotion-cache.production.min.js\"\n ),\n resolveModule(\n \"./esm-externals/emotion-cache.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 \"/virtual/main.tsx\": `import React, { Suspense } from \"react\";\n import ReactDOM from \"react-dom/client\";\n import App from \"virtual:App.tsx\";\n \n const root = ReactDOM.createRoot(document.getElementById(\"hv-root\"));\n \n root.render(React.createElement(\n Suspense,\n { fallback: true },\n React.createElement(App, null)\n ));`,\n \"virtual:App.tsx\": `import React from \"react\";\n import { HvAppShell } from \"@hitachivantara/app-shell\";\n\n const App = () => {\n return React.createElement(HvAppShell, {\n configUrl: window.location.origin + APP_BASE_PATH + \"app-shell.config.json\"\n });\n };\n \n export default App;`,\n\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/emotion-react.production.min.js\": `export * from \"@emotion/react\";`,\n \"/bundles/emotion-cache.production.min.js\": `import createCache from \"@emotion/cache\"; export default createCache;`,\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 \"@emotion/react\": \"./bundles/emotion-react.production.min.js\",\n \"@emotion/cache\": \"./bundles/emotion-cache.production.min.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 \"@emotion/react\",\n \"@emotion/cache\",\n \"@self\",\n packageJson.name\n ],\n externalImportMap && buildEntryPoint\n ),\n buildEntryPoint && generateBaseTag(appShellConfiguration),\n // process configuration\n processConfiguration(\n root,\n appShellConfiguration,\n packageJson.name,\n buildEntryPoint\n ),\n serveAppShellConfig(\n appShellConfiguration,\n root,\n appShellConfigFile,\n autoViewsAndRoutes ? viewsFolder : undefined\n )\n ];\n}\n\nexport default appShellVitePlugin;\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hitachivantara/app-shell-vite-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "AppShell Vite Plugin",
|
|
5
5
|
"author": "Hitachi Vantara - Boba Fett Team",
|
|
6
6
|
"type": "module",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@emotion/cache": "^11.11.0",
|
|
36
36
|
"@emotion/react": "^11.11.1",
|
|
37
|
-
"@hitachivantara/app-shell-shared": "0.8.
|
|
38
|
-
"@hitachivantara/uikit-react-shared": "5.1.0",
|
|
37
|
+
"@hitachivantara/app-shell-shared": "0.8.3",
|
|
38
|
+
"@hitachivantara/uikit-react-shared": "^5.1.0",
|
|
39
39
|
"@rollup/plugin-commonjs": "^24.0.0",
|
|
40
40
|
"@rollup/plugin-json": "^6.0.0",
|
|
41
41
|
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"@types/react-dom": "^18.0.11",
|
|
57
57
|
"tsc-watch": "^6.0.0"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "5dd5bf002e6c8ecb425c3ea2d39f59ea73341e8b"
|
|
60
60
|
}
|