@hitachivantara/app-shell-vite-plugin 1.4.4 → 1.4.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,YAAY,EAAE,MAAM,MAAM,CAAC;AAa7C,OAAO,EACL,iBAAiB,EAIlB,MAAM,mBAAmB,CAAC;AAc3B,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErD,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAE7B;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEzC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,iBAAS,kBAAkB,CACzB,IAAI,GAAE,yBAA8B,EACpC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC/B,YAAY,
|
|
1
|
+
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAMA,OAAO,EAAW,YAAY,EAAE,MAAM,MAAM,CAAC;AAa7C,OAAO,EACL,iBAAiB,EAIlB,MAAM,mBAAmB,CAAC;AAc3B,MAAM,MAAM,qBAAqB,GAAG,KAAK,GAAG,QAAQ,CAAC;AAErD,MAAM,WAAW,yBAAyB;IACxC;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAE7B;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEzC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;;;;;OAQG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;;;;;;OAOG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;GAIG;AACH,iBAAS,kBAAkB,CACzB,IAAI,GAAE,yBAA8B,EACpC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC/B,YAAY,CAgLd;AAED,eAAe,kBAAkB,CAAC"}
|
package/dist/vite-plugin.js
CHANGED
|
@@ -66,10 +66,15 @@ function appShellVitePlugin(opts = {}, env = {}) {
|
|
|
66
66
|
...(!devMode && buildEntryPoint
|
|
67
67
|
? [
|
|
68
68
|
{
|
|
69
|
-
src: SHARED_DEPENDENCIES.flatMap(dep =>
|
|
70
|
-
resolveModule(dep.bundleSrc)
|
|
71
|
-
|
|
72
|
-
|
|
69
|
+
src: SHARED_DEPENDENCIES.flatMap(dep => {
|
|
70
|
+
const module = resolveModule(dep.bundleSrc);
|
|
71
|
+
try {
|
|
72
|
+
return [module, resolveModule(`${dep.bundleSrc}.map`)];
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return [module];
|
|
76
|
+
}
|
|
77
|
+
}),
|
|
73
78
|
dest: "bundles"
|
|
74
79
|
}
|
|
75
80
|
]
|
package/dist/vite-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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;AAExB,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAgB,MAAM,MAAM,CAAC;AAI7C,OAAO,iBAAiB,EAAE,EACxB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAC5E,OAAO,eAAe,MAAM,gCAAgC,CAAC;AAC7D,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,mBAAmB,MAAM,+BAA+B,CAAC;AAChE,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAEL,sBAAsB,EACtB,kBAAkB,EAClB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EACL,kBAAkB,EAClB,4BAA4B,EAC7B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D,IAAK,aAGJ;AAHD,WAAK,aAAa;IAChB,0CA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AG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,WAAW,CAAC,IAAI,CAAC,EACnE,iBAAiB,IAAI,eAAe,EACpC,kBAAkB,CACnB;QAED,4CAA4C;QAC5C,eAAe,IAAI,cAAc,EAAE;QAEnC,2DAA2D;QAC3D,eAAe;YACb,eAAe,CAAC,qBAAqB,EAAE,kBAAkB,CAAC;QAE5D,uDAAuD;QACvD,oBAAoB,CAClB,IAAI,EACJ,qBAAqB,EACrB,WAAW,CAAC,IAAI,EAChB,eAAe,EACf,YAAY,EACZ,kBAAkB,EAClB,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CACjC;QAED,gEAAgE;QAChE,mBAAmB,CACjB,qBAAqB,EACrB,IAAI,EACJ,WAAW,CAAC,IAAI,EAChB,kBAAkB,EAClB,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAC7C;QAED,0EAA0E;QAC1E,kBAAkB,IAAI,kBAAkB,CAAC,iBAAiB,EAAE,YAAY,CAAC;KAC1E,CAAC;AACJ,CAAC;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport virtual from \"@rollup/plugin-virtual\";\nimport { viteStaticCopy } from \"vite-plugin-static-copy\";\n\nimport { loadEnv, PluginOption } from \"vite\";\n\nimport type { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\n\nimport generateImportmap, {\n extraDependencies\n} from \"./vite-importmap-plugin.js\";\nimport processConfiguration from \"./vite-configuration-processor-plugin.js\";\nimport generateBaseTag from \"./vite-generate-base-plugin.js\";\nimport injectMetadata from \"./vite-metadata-plugin.js\";\nimport serveAppShellConfig from \"./vite-watch-config-plugin.js\";\nimport generateBashScript from \"./vite-generate-bash-script-plugin.js\";\n\nimport {\n ConfigReplacement,\n findAppShellConfigFile,\n getFinalModuleName,\n loadConfigFile\n} from \"./config-utils.js\";\nimport { getModulePath, resolveModule } from \"./nodeModule.js\";\nimport {\n applyAutomaticMenu,\n applyAutomaticViewsAndRoutes\n} from \"./automatic-utils.js\";\nimport getVirtualEntrypoints from \"./virtual-entrypoints.js\";\nimport SHARED_DEPENDENCIES from \"./shared-dependencies.js\";\n\nenum ViteBuildMode {\n PRODUCTION = \"production\",\n DEVELOPMENT = \"development\"\n}\n\nexport type ApplicationBundleType = \"app\" | \"bundle\";\n\nexport interface AppShellVitePluginOptions {\n /**\n * Project root directory. Most likely the 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 /**\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?: ApplicationBundleType;\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 * \"@hv/user-notifications-client\": \"@@USER_NOTIFICATIONS_URL@@\"\n * }\n */\n configReplacements?: ConfigReplacement[];\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 * Any menu defined in the App Shell config file will be overwritten.\n */\n autoMenu?: boolean;\n\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 * This option is not for general use. It is only intended to be used for easing the automated testing of the App Shell.\n *\n * @default false\n * @private\n */\n externalImportMap?: boolean;\n /**\n * If true, the plugin will inline the app-shell.config.json file in a script tag of the index html.\n *\n * This option is not for general use. Its value will be automatically managed by the App Shell build process.\n *\n * @default false, true if generateEmptyShell is true\n * @private\n */\n inlineConfig?: boolean;\n /**\n * If true, the config file is ignored, only the App Shell is built and the generated index.html will contain a placeholders\n * for importmap (if externalImportMap is false), app shell config (if inlineConfig is true) and title.\n *\n * A bash script will also be added to the dist folder to replace the placeholders with the actual content,\n * when provided with a concrete configuration.\n *\n * This option is not for general use. It is used for generating the App Shell container image.\n *\n * @default false\n * @private\n */\n generateEmptyShell?: boolean;\n /**\n * The modules to be exported by the application.\n *\n * All the modules that the application need to export should be declared here in order to have them built properly.\n *\n */\n modules?: string[];\n}\n\n/**\n * Vite plugin to support App Shell apps setup\n * @param opts Plugin options\n * @param env Environment variable\n */\nfunction 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 viewsFolder = \"src/pages\",\n autoViewsAndRoutes = false,\n autoMenu = false,\n inlineConfig = opts.generateEmptyShell ?? false,\n generateEmptyShell = false,\n modules = []\n } = opts;\n\n const globalEnv = loadEnv(mode, process.cwd(), \"\");\n\n const { type = globalEnv.CI ? \"bundle\" : \"app\" } = opts;\n\n console.info(`Vite running in mode: ${mode}`);\n console.info(`AppShell Vite plugin running with type: ${type}`);\n\n const devMode = mode === ViteBuildMode.DEVELOPMENT;\n const buildEntryPoint = type !== \"bundle\";\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 = !generateEmptyShell\n ? findAppShellConfigFile(root)\n : undefined;\n const appShellConfiguration: HvAppShellConfig = loadConfigFile(\n appShellConfigFile,\n opts,\n env\n );\n\n let autoViewsBundles: string[] = [];\n\n if (!generateEmptyShell) {\n if (autoViewsAndRoutes) {\n autoViewsBundles = applyAutomaticViewsAndRoutes(\n appShellConfiguration,\n packageJson.name,\n root,\n viewsFolder\n );\n }\n\n if (autoMenu) {\n applyAutomaticMenu(appShellConfiguration);\n }\n }\n\n return [\n // copy the shared dependencies js bundles to the \"bundles\" folder\n (buildEntryPoint || devMode) &&\n viteStaticCopy({\n targets: [\n {\n src: getModulePath(\"es-module-shims\", \"dist/*\"),\n dest: \"bundles\"\n },\n // copy the ui kit icons' sprites to the \"icons\" folder\n {\n src: [\n getModulePath(\n \"@hitachivantara/uikit-react-icons\",\n \"dist/sprites/*.svg\"\n )\n ],\n dest: \"icons\"\n },\n ...(!devMode && buildEntryPoint\n ? [\n {\n src: SHARED_DEPENDENCIES.flatMap(dep => [\n resolveModule(dep.bundleSrc),\n resolveModule(`${dep.bundleSrc}.map`)\n ]),\n dest: \"bundles\"\n }\n ]\n : [])\n ]\n }),\n\n // create virtual endpoints for shell code and for shared dependencies\n virtual({\n ...getVirtualEntrypoints(inlineConfig),\n\n ...SHARED_DEPENDENCIES.reduce(\n (acc, dep) => {\n acc[`/bundles/${dep.bundle}`] = dep.virtualSrc;\n return acc;\n },\n {} as Record<string, string>\n )\n }),\n\n // generate the importmap for shared dependencies and for apps referenced in the config file\n generateImportmap(\n {\n ...SHARED_DEPENDENCIES.reduce(\n (acc, dep) => {\n acc[dep.moduleId] = `./bundles/${dep.bundle}`;\n return acc;\n },\n {} as Record<string, string>\n ),\n\n ...extraDependencies,\n\n ...Object.entries(appShellConfiguration?.apps ?? {}).reduce(\n (acc, [key, value]) => {\n acc[`${key}/`] = value;\n return acc;\n },\n {} as Record<string, string>\n ),\n\n [`${packageJson.name}/`]: appShellConfiguration.baseUrl ?? \"/\",\n\n ...(devMode\n ? modules.concat(autoViewsBundles).reduce(\n (acc, module) => {\n const finalModule = getFinalModuleName(module);\n acc[`${packageJson.name}/${finalModule}.js`] =\n (appShellConfiguration.baseUrl ?? \"/\") + module;\n return acc;\n },\n {} as Record<string, string>\n )\n : {})\n },\n packageJson.name,\n [...SHARED_DEPENDENCIES.map(dep => dep.moduleId), packageJson.name],\n externalImportMap && buildEntryPoint,\n generateEmptyShell\n ),\n\n // inject version metadata in the index.html\n buildEntryPoint && injectMetadata(),\n\n // set the base tag and replace the title in the index.html\n buildEntryPoint &&\n generateBaseTag(appShellConfiguration, generateEmptyShell),\n\n // configure the build process based on the config file\n processConfiguration(\n root,\n appShellConfiguration,\n packageJson.name,\n buildEntryPoint,\n inlineConfig,\n generateEmptyShell,\n modules.concat(autoViewsBundles)\n ),\n\n // serve the app shell config file as json and watch for changes\n serveAppShellConfig(\n appShellConfiguration,\n root,\n packageJson.name,\n appShellConfigFile,\n autoViewsAndRoutes ? viewsFolder : undefined\n ),\n\n // generate the shell script to replace the placeholders in the index.html\n generateEmptyShell && generateBashScript(externalImportMap, inlineConfig)\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;AAExB,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEzD,OAAO,EAAE,OAAO,EAAgB,MAAM,MAAM,CAAC;AAI7C,OAAO,iBAAiB,EAAE,EACxB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AACpC,OAAO,oBAAoB,MAAM,0CAA0C,CAAC;AAC5E,OAAO,eAAe,MAAM,gCAAgC,CAAC;AAC7D,OAAO,cAAc,MAAM,2BAA2B,CAAC;AACvD,OAAO,mBAAmB,MAAM,+BAA+B,CAAC;AAChE,OAAO,kBAAkB,MAAM,uCAAuC,CAAC;AAEvE,OAAO,EAEL,sBAAsB,EACtB,kB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up/plugin-virtual\";\nimport { viteStaticCopy } from \"vite-plugin-static-copy\";\n\nimport { loadEnv, PluginOption } from \"vite\";\n\nimport type { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\n\nimport generateImportmap, {\n extraDependencies\n} from \"./vite-importmap-plugin.js\";\nimport processConfiguration from \"./vite-configuration-processor-plugin.js\";\nimport generateBaseTag from \"./vite-generate-base-plugin.js\";\nimport injectMetadata from \"./vite-metadata-plugin.js\";\nimport serveAppShellConfig from \"./vite-watch-config-plugin.js\";\nimport generateBashScript from \"./vite-generate-bash-script-plugin.js\";\n\nimport {\n ConfigReplacement,\n findAppShellConfigFile,\n getFinalModuleName,\n loadConfigFile\n} from \"./config-utils.js\";\nimport { getModulePath, resolveModule } from \"./nodeModule.js\";\nimport {\n applyAutomaticMenu,\n applyAutomaticViewsAndRoutes\n} from \"./automatic-utils.js\";\nimport getVirtualEntrypoints from \"./virtual-entrypoints.js\";\nimport SHARED_DEPENDENCIES from \"./shared-dependencies.js\";\n\nenum ViteBuildMode {\n PRODUCTION = \"production\",\n DEVELOPMENT = \"development\"\n}\n\nexport type ApplicationBundleType = \"app\" | \"bundle\";\n\nexport interface AppShellVitePluginOptions {\n /**\n * Project root directory. Most likely the 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 /**\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?: ApplicationBundleType;\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 * \"@hv/user-notifications-client\": \"@@USER_NOTIFICATIONS_URL@@\"\n * }\n */\n configReplacements?: ConfigReplacement[];\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 * Any menu defined in the App Shell config file will be overwritten.\n */\n autoMenu?: boolean;\n\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 * This option is not for general use. It is only intended to be used for easing the automated testing of the App Shell.\n *\n * @default false\n * @private\n */\n externalImportMap?: boolean;\n /**\n * If true, the plugin will inline the app-shell.config.json file in a script tag of the index html.\n *\n * This option is not for general use. Its value will be automatically managed by the App Shell build process.\n *\n * @default false, true if generateEmptyShell is true\n * @private\n */\n inlineConfig?: boolean;\n /**\n * If true, the config file is ignored, only the App Shell is built and the generated index.html will contain a placeholders\n * for importmap (if externalImportMap is false), app shell config (if inlineConfig is true) and title.\n *\n * A bash script will also be added to the dist folder to replace the placeholders with the actual content,\n * when provided with a concrete configuration.\n *\n * This option is not for general use. It is used for generating the App Shell container image.\n *\n * @default false\n * @private\n */\n generateEmptyShell?: boolean;\n /**\n * The modules to be exported by the application.\n *\n * All the modules that the application need to export should be declared here in order to have them built properly.\n *\n */\n modules?: string[];\n}\n\n/**\n * Vite plugin to support App Shell apps setup\n * @param opts Plugin options\n * @param env Environment variable\n */\nfunction 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 viewsFolder = \"src/pages\",\n autoViewsAndRoutes = false,\n autoMenu = false,\n inlineConfig = opts.generateEmptyShell ?? false,\n generateEmptyShell = false,\n modules = []\n } = opts;\n\n const globalEnv = loadEnv(mode, process.cwd(), \"\");\n\n const { type = globalEnv.CI ? \"bundle\" : \"app\" } = opts;\n\n console.info(`Vite running in mode: ${mode}`);\n console.info(`AppShell Vite plugin running with type: ${type}`);\n\n const devMode = mode === ViteBuildMode.DEVELOPMENT;\n const buildEntryPoint = type !== \"bundle\";\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 = !generateEmptyShell\n ? findAppShellConfigFile(root)\n : undefined;\n const appShellConfiguration: HvAppShellConfig = loadConfigFile(\n appShellConfigFile,\n opts,\n env\n );\n\n let autoViewsBundles: string[] = [];\n\n if (!generateEmptyShell) {\n if (autoViewsAndRoutes) {\n autoViewsBundles = applyAutomaticViewsAndRoutes(\n appShellConfiguration,\n packageJson.name,\n root,\n viewsFolder\n );\n }\n\n if (autoMenu) {\n applyAutomaticMenu(appShellConfiguration);\n }\n }\n\n return [\n // copy the shared dependencies js bundles to the \"bundles\" folder\n (buildEntryPoint || devMode) &&\n viteStaticCopy({\n targets: [\n {\n src: getModulePath(\"es-module-shims\", \"dist/*\"),\n dest: \"bundles\"\n },\n // copy the ui kit icons' sprites to the \"icons\" folder\n {\n src: [\n getModulePath(\n \"@hitachivantara/uikit-react-icons\",\n \"dist/sprites/*.svg\"\n )\n ],\n dest: \"icons\"\n },\n ...(!devMode && buildEntryPoint\n ? [\n {\n src: SHARED_DEPENDENCIES.flatMap(dep => {\n const module = resolveModule(dep.bundleSrc);\n try {\n return [module, resolveModule(`${dep.bundleSrc}.map`)];\n } catch {\n return [module];\n }\n }),\n dest: \"bundles\"\n }\n ]\n : [])\n ]\n }),\n\n // create virtual endpoints for shell code and for shared dependencies\n virtual({\n ...getVirtualEntrypoints(inlineConfig),\n\n ...SHARED_DEPENDENCIES.reduce(\n (acc, dep) => {\n acc[`/bundles/${dep.bundle}`] = dep.virtualSrc;\n return acc;\n },\n {} as Record<string, string>\n )\n }),\n\n // generate the importmap for shared dependencies and for apps referenced in the config file\n generateImportmap(\n {\n ...SHARED_DEPENDENCIES.reduce(\n (acc, dep) => {\n acc[dep.moduleId] = `./bundles/${dep.bundle}`;\n return acc;\n },\n {} as Record<string, string>\n ),\n\n ...extraDependencies,\n\n ...Object.entries(appShellConfiguration?.apps ?? {}).reduce(\n (acc, [key, value]) => {\n acc[`${key}/`] = value;\n return acc;\n },\n {} as Record<string, string>\n ),\n\n [`${packageJson.name}/`]: appShellConfiguration.baseUrl ?? \"/\",\n\n ...(devMode\n ? modules.concat(autoViewsBundles).reduce(\n (acc, module) => {\n const finalModule = getFinalModuleName(module);\n acc[`${packageJson.name}/${finalModule}.js`] =\n (appShellConfiguration.baseUrl ?? \"/\") + module;\n return acc;\n },\n {} as Record<string, string>\n )\n : {})\n },\n packageJson.name,\n [...SHARED_DEPENDENCIES.map(dep => dep.moduleId), packageJson.name],\n externalImportMap && buildEntryPoint,\n generateEmptyShell\n ),\n\n // inject version metadata in the index.html\n buildEntryPoint && injectMetadata(),\n\n // set the base tag and replace the title in the index.html\n buildEntryPoint &&\n generateBaseTag(appShellConfiguration, generateEmptyShell),\n\n // configure the build process based on the config file\n processConfiguration(\n root,\n appShellConfiguration,\n packageJson.name,\n buildEntryPoint,\n inlineConfig,\n generateEmptyShell,\n modules.concat(autoViewsBundles)\n ),\n\n // serve the app shell config file as json and watch for changes\n serveAppShellConfig(\n appShellConfiguration,\n root,\n packageJson.name,\n appShellConfigFile,\n autoViewsAndRoutes ? viewsFolder : undefined\n ),\n\n // generate the shell script to replace the placeholders in the index.html\n generateEmptyShell && generateBashScript(externalImportMap, inlineConfig)\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": "1.4.
|
|
3
|
+
"version": "1.4.5",
|
|
4
4
|
"description": "AppShell Vite Plugin",
|
|
5
5
|
"author": "Hitachi Vantara - Boba Fett Team",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -64,5 +64,5 @@
|
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"vite": "^4.1.4 || ^5.0.4"
|
|
66
66
|
},
|
|
67
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "befc71ba5068314561da2717090844bb10f85f53"
|
|
68
68
|
}
|