@hitachivantara/app-shell-vite-plugin 0.12.1 → 0.13.0

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.
Files changed (47) hide show
  1. package/README.md +0 -15
  2. package/dist/automatic-utils.d.ts +6 -0
  3. package/dist/automatic-utils.d.ts.map +1 -0
  4. package/dist/automatic-utils.js +105 -0
  5. package/dist/automatic-utils.js.map +1 -0
  6. package/dist/config-utils.d.ts +34 -0
  7. package/dist/config-utils.d.ts.map +1 -0
  8. package/dist/config-utils.js +126 -0
  9. package/dist/config-utils.js.map +1 -0
  10. package/dist/index.d.ts +0 -8
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/shared-dependencies.d.ts +8 -0
  14. package/dist/shared-dependencies.d.ts.map +1 -0
  15. package/dist/shared-dependencies.js +87 -0
  16. package/dist/shared-dependencies.js.map +1 -0
  17. package/dist/virtual-entrypoints.d.ts +5 -0
  18. package/dist/virtual-entrypoints.d.ts.map +1 -0
  19. package/dist/virtual-entrypoints.js +37 -0
  20. package/dist/virtual-entrypoints.js.map +1 -0
  21. package/dist/vite-configuration-processor-plugin.d.ts +14 -0
  22. package/dist/vite-configuration-processor-plugin.d.ts.map +1 -0
  23. package/dist/vite-configuration-processor-plugin.js +161 -0
  24. package/dist/vite-configuration-processor-plugin.js.map +1 -0
  25. package/dist/vite-generate-base-plugin.d.ts +8 -0
  26. package/dist/vite-generate-base-plugin.d.ts.map +1 -0
  27. package/dist/vite-generate-base-plugin.js +32 -0
  28. package/dist/vite-generate-base-plugin.js.map +1 -0
  29. package/dist/vite-generate-bash-script-plugin.d.ts +3 -0
  30. package/dist/vite-generate-bash-script-plugin.d.ts.map +1 -0
  31. package/dist/vite-generate-bash-script-plugin.js +122 -0
  32. package/dist/vite-generate-bash-script-plugin.js.map +1 -0
  33. package/dist/vite-importmap-plugin.d.ts +2 -2
  34. package/dist/vite-importmap-plugin.d.ts.map +1 -1
  35. package/dist/vite-importmap-plugin.js +15 -4
  36. package/dist/vite-importmap-plugin.js.map +1 -1
  37. package/dist/vite-metadata-plugin.d.ts.map +1 -1
  38. package/dist/vite-metadata-plugin.js.map +1 -1
  39. package/dist/vite-plugin.d.ts +36 -13
  40. package/dist/vite-plugin.d.ts.map +1 -1
  41. package/dist/vite-plugin.js +49 -525
  42. package/dist/vite-plugin.js.map +1 -1
  43. package/dist/vite-watch-config-plugin.d.ts +4 -0
  44. package/dist/vite-watch-config-plugin.d.ts.map +1 -0
  45. package/dist/vite-watch-config-plugin.js +41 -0
  46. package/dist/vite-watch-config-plugin.js.map +1 -0
  47. package/package.json +2 -2
@@ -0,0 +1,161 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { getAppModules, getMainApp, getPublicPath } from "./config-utils.js";
4
+ var ViteCommand;
5
+ (function (ViteCommand) {
6
+ ViteCommand["BUILD"] = "build";
7
+ ViteCommand["SERVE"] = "serve";
8
+ })(ViteCommand || (ViteCommand = {}));
9
+ /**
10
+ * Process configuration, executing several tasks:
11
+ * - Create rollup configuration to support module creation
12
+ * - Generates final transformed configuration json
13
+ * - "base" value is always "./" for build, and main app baseUrl for preview or dev
14
+ * @param root Project root directory.
15
+ * @param appShellConfig The original App Shell configuration json.
16
+ * @param selfAppName The name of the application bundle being built.
17
+ * @param buildEntryPoint If true, the index.html entry point will be added to the bundle.
18
+ */
19
+ export default function processConfiguration(root, appShellConfig, selfAppName, buildEntryPoint, inlineConfig, generateEmptyShell) {
20
+ const selfApp = getMainApp(appShellConfig);
21
+ let finalAppShellConfig;
22
+ return {
23
+ name: "vite-plugin-appShell-configuration-processor",
24
+ config(config, { command }) {
25
+ const projectRoot = root ?? config.root;
26
+ const publicPath = getPublicPath(appShellConfig);
27
+ let appModules = {};
28
+ if (!generateEmptyShell) {
29
+ appModules = getAppModules(projectRoot, appShellConfig, selfAppName);
30
+ console.info("Modules exported by the application bundle:", appModules);
31
+ }
32
+ return {
33
+ build: {
34
+ rollupOptions: {
35
+ preserveEntrySignatures: "strict",
36
+ input: {
37
+ ...(buildEntryPoint &&
38
+ fs.existsSync(path.resolve(projectRoot, "index.html"))
39
+ ? { main: path.resolve(projectRoot, "index.html") }
40
+ : {}),
41
+ ...appModules
42
+ },
43
+ output: {
44
+ entryFileNames: "[name].js"
45
+ }
46
+ }
47
+ },
48
+ // if serve (preview/dev) it uses the baseUrl. Otherwise(build), use ./
49
+ base: command === ViteCommand.SERVE ? publicPath : "./"
50
+ };
51
+ },
52
+ /**
53
+ * Rollup hook with the info for bundle generation
54
+ * It will be used to create a new configuration with:
55
+ * - bundles replace with the final location (e.g. -> "bundle": "src/pages/Main" transformed to "bundle": "pages/Main.js",
56
+ * @param options build options
57
+ * @param bundle bundles information
58
+ */
59
+ async generateBundle(options, bundle) {
60
+ if (generateEmptyShell) {
61
+ return;
62
+ }
63
+ // obtain the directory (dist) where the new config file will be placed
64
+ let targetDir;
65
+ if (options.dir) {
66
+ targetDir = options.dir;
67
+ }
68
+ else if (options.file) {
69
+ targetDir = path.dirname(options.file);
70
+ }
71
+ if (!targetDir) {
72
+ throw new Error("Please set outputPath, so we can know where to place the json file");
73
+ }
74
+ // create the targetDir if it does not exist
75
+ if (!fs.existsSync(targetDir)) {
76
+ fs.mkdirSync(targetDir, { recursive: true });
77
+ }
78
+ /**
79
+ * Creating a map with each chunk and the final name. Only the bundles with type=chunk are important
80
+ * Filename do not include the src path at the value
81
+ */
82
+ const chunks = {};
83
+ Object.keys(bundle).forEach(key => {
84
+ const chunk = bundle[key];
85
+ if (chunk.type === "chunk") {
86
+ const outputChunk = chunk;
87
+ if (outputChunk.isEntry) {
88
+ const { fileName } = outputChunk;
89
+ const { name } = outputChunk;
90
+ chunks[name] = fileName;
91
+ }
92
+ }
93
+ });
94
+ if (selfApp) {
95
+ selfApp.views = selfApp.views?.map(view => {
96
+ const bundleName = view.bundle
97
+ .replace(/^src\//, "")
98
+ .replaceAll(/\$/g, "_");
99
+ return {
100
+ ...view,
101
+ bundle: chunks[bundleName]
102
+ };
103
+ });
104
+ selfApp.modules = selfApp.modules?.map(module => {
105
+ const bundleName = module.bundle.replace(/^src\//, "");
106
+ return {
107
+ ...module,
108
+ bundle: chunks[bundleName]
109
+ };
110
+ });
111
+ // replace references to @self with the name of this application bundle
112
+ selfApp.id = selfAppName;
113
+ // also replace implicit references to selfApp in other parts of the configuration
114
+ const { theming } = appShellConfig;
115
+ if (theming != null) {
116
+ theming.themes = theming.themes?.map(theme => {
117
+ if (theme.startsWith("@self/") ||
118
+ theme.startsWith(selfAppName) ||
119
+ theme.startsWith("/src/")) {
120
+ const bundleName = theme
121
+ .replace(/^@self\//, "")
122
+ .replace(new RegExp(`^${selfAppName}/`), "")
123
+ .replace(/^(\/?)src\//, "");
124
+ return `${selfAppName}/${chunks[bundleName]}`;
125
+ }
126
+ return theme;
127
+ });
128
+ }
129
+ }
130
+ finalAppShellConfig = buildEntryPoint
131
+ ? { ...appShellConfig }
132
+ : {
133
+ name: appShellConfig.name,
134
+ apps: selfApp != null ? [selfApp] : undefined
135
+ };
136
+ if (!inlineConfig) {
137
+ fs.writeFileSync(path.resolve(targetDir, "app-shell.config.json"), JSON.stringify(finalAppShellConfig));
138
+ }
139
+ },
140
+ transformIndexHtml: {
141
+ transform: html => {
142
+ if (!inlineConfig) {
143
+ return undefined;
144
+ }
145
+ return {
146
+ html,
147
+ tags: [
148
+ {
149
+ tag: "script",
150
+ injectTo: "head-prepend",
151
+ children: `globalThis.__appshell_config__ = ${generateEmptyShell
152
+ ? "%%APPSHELL_CONFIG%%"
153
+ : JSON.stringify(finalAppShellConfig ?? appShellConfig)};`
154
+ }
155
+ ]
156
+ };
157
+ }
158
+ }
159
+ };
160
+ }
161
+ //# sourceMappingURL=vite-configuration-processor-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-configuration-processor-plugin.js","sourceRoot":"","sources":["../src/vite-configuration-processor-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,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AAG,CAAC,EAAE,EAAE,CAAC;iCAC3C,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;4BAC9B,OAAO,GAAG,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC;yBAC/C;wBAED,OAAO,KAAK,CAAC;oBACf,CAAC,CAAC,CAAC;iBACJ;aACF;YAED,mBAAmB,GAAG,eAAe;gBACnC,CAAC,CAAC,EAAE,GAAG,cAAc,EAAE;gBACvB,CAAC,CAAC;oBACE,IAAI,EAAE,cAAc,CAAC,IAAI;oBACzB,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS;iBAC9C,CAAC;YAEN,IAAI,CAAC,YAAY,EAAE;gBACjB,EAAE,CAAC,aAAa,CACd,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,uBAAuB,CAAC,EAChD,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CACpC,CAAC;aACH;QACH,CAAC;QAED,kBAAkB,EAAE;YAClB,SAAS,EAAE,IAAI,CAAC,EAAE;gBAChB,IAAI,CAAC,YAAY,EAAE;oBACjB,OAAO,SAAS,CAAC;iBAClB;gBAED,OAAO;oBACL,IAAI;oBAEJ,IAAI,EAAE;wBACJ;4BACE,GAAG,EAAE,QAAQ;4BACb,QAAQ,EAAE,cAAc;4BACxB,QAAQ,EAAE,oCACR,kBAAkB;gCAChB,CAAC,CAAC,qBAAqB;gCACvB,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,mBAAmB,IAAI,cAAc,CAC1D,GAAG;yBACJ;qBACF;iBACF,CAAC;YACJ,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport type { PluginOption, UserConfig } from \"vite\";\nimport type { NormalizedOutputOptions, OutputBundle } from \"rollup\";\n\nimport type { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\n\nimport { getAppModules, getMainApp, getPublicPath } from \"./config-utils.js\";\n\nenum ViteCommand {\n BUILD = \"build\",\n SERVE = \"serve\"\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 * @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 */\nexport default function processConfiguration(\n root: string,\n appShellConfig: HvAppShellConfig,\n selfAppName: string,\n buildEntryPoint: boolean,\n inlineConfig: boolean,\n generateEmptyShell: boolean\n): PluginOption {\n const selfApp = getMainApp(appShellConfig);\n let finalAppShellConfig: HvAppShellConfig;\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 let appModules = {};\n if (!generateEmptyShell) {\n appModules = getAppModules(projectRoot, appShellConfig, selfAppName);\n console.info(\"Modules exported by the application bundle:\", appModules);\n }\n\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 ...appModules\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 };\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 if (generateEmptyShell) {\n return;\n }\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=chunk 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 finalAppShellConfig = buildEntryPoint\n ? { ...appShellConfig }\n : {\n name: appShellConfig.name,\n apps: selfApp != null ? [selfApp] : undefined\n };\n\n if (!inlineConfig) {\n fs.writeFileSync(\n path.resolve(targetDir, \"app-shell.config.json\"),\n JSON.stringify(finalAppShellConfig)\n );\n }\n },\n\n transformIndexHtml: {\n transform: html => {\n if (!inlineConfig) {\n return undefined;\n }\n\n return {\n html,\n\n tags: [\n {\n tag: \"script\",\n injectTo: \"head-prepend\",\n children: `globalThis.__appshell_config__ = ${\n generateEmptyShell\n ? \"%%APPSHELL_CONFIG%%\"\n : JSON.stringify(finalAppShellConfig ?? appShellConfig)\n };`\n }\n ]\n };\n }\n }\n };\n}\n"]}
@@ -0,0 +1,8 @@
1
+ import type { PluginOption } from "vite";
2
+ import type { HvAppShellConfig } from "@hitachivantara/app-shell-shared";
3
+ /**
4
+ * Add the <BASE> tag at index.html file. Tag value is obtained by the main app ({@link #getMainApp}) baseUrl ({@link #getPublicPath})‘
5
+ * @param appShellConfig The app shell configuration.
6
+ */
7
+ export default function generateBaseTag(appShellConfig: HvAppShellConfig, generateEmptyShell: boolean): PluginOption;
8
+ //# sourceMappingURL=vite-generate-base-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-generate-base-plugin.d.ts","sourceRoot":"","sources":["../src/vite-generate-base-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAIzE;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,cAAc,EAAE,gBAAgB,EAChC,kBAAkB,EAAE,OAAO,GAC1B,YAAY,CAgCd"}
@@ -0,0 +1,32 @@
1
+ import { getPublicPath } from "./config-utils.js";
2
+ /**
3
+ * Add the <BASE> tag at index.html file. Tag value is obtained by the main app ({@link #getMainApp}) baseUrl ({@link #getPublicPath})‘
4
+ * @param appShellConfig The app shell configuration.
5
+ */
6
+ export default function generateBaseTag(appShellConfig, generateEmptyShell) {
7
+ const publicPath = getPublicPath(appShellConfig);
8
+ return {
9
+ name: "vite-plugin-generate-base",
10
+ enforce: "pre",
11
+ transformIndexHtml: {
12
+ enforce: "post",
13
+ transform: (html) => ({
14
+ html: generateEmptyShell || appShellConfig.name != null
15
+ ? html.replace(/<title>(.*?)<\/title>/, `<title>${generateEmptyShell
16
+ ? "%%APPSHELL_TITLE%%"
17
+ : appShellConfig.name}</title>`)
18
+ : html,
19
+ tags: [
20
+ {
21
+ tag: "base",
22
+ attrs: {
23
+ href: generateEmptyShell ? "%%APPSHELL_BASE%%" : publicPath
24
+ },
25
+ injectTo: "head-prepend"
26
+ }
27
+ ]
28
+ })
29
+ }
30
+ };
31
+ }
32
+ //# sourceMappingURL=vite-generate-base-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-generate-base-plugin.js","sourceRoot":"","sources":["../src/vite-generate-base-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,OAAO,UAAU,eAAe,CACrC,cAAgC,EAChC,kBAA2B;IAE3B,MAAM,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;IAEjD,OAAO;QACL,IAAI,EAAE,2BAA2B;QACjC,OAAO,EAAE,KAAK;QACd,kBAAkB,EAAE;YAClB,OAAO,EAAE,MAAM;YACf,SAAS,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,CAAC;gBAC5B,IAAI,EACF,kBAAkB,IAAI,cAAc,CAAC,IAAI,IAAI,IAAI;oBAC/C,CAAC,CAAC,IAAI,CAAC,OAAO,CACV,uBAAuB,EACvB,UACE,kBAAkB;wBAChB,CAAC,CAAC,oBAAoB;wBACtB,CAAC,CAAC,cAAc,CAAC,IACrB,UAAU,CACX;oBACH,CAAC,CAAC,IAAI;gBACV,IAAI,EAAE;oBACJ;wBACE,GAAG,EAAE,MAAM;wBACX,KAAK,EAAE;4BACL,IAAI,EAAE,kBAAkB,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,UAAU;yBAC5D;wBACD,QAAQ,EAAE,cAAc;qBACzB;iBACF;aACF,CAAC;SACH;KACF,CAAC;AACJ,CAAC","sourcesContent":["import type { PluginOption } from \"vite\";\n\nimport type { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\n\nimport { getPublicPath } from \"./config-utils.js\";\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 */\nexport default function generateBaseTag(\n appShellConfig: HvAppShellConfig,\n generateEmptyShell: boolean\n): PluginOption {\n const publicPath = getPublicPath(appShellConfig);\n\n return {\n name: \"vite-plugin-generate-base\",\n enforce: \"pre\",\n transformIndexHtml: {\n enforce: \"post\",\n transform: (html: string) => ({\n html:\n generateEmptyShell || appShellConfig.name != null\n ? html.replace(\n /<title>(.*?)<\\/title>/,\n `<title>${\n generateEmptyShell\n ? \"%%APPSHELL_TITLE%%\"\n : appShellConfig.name\n }</title>`\n )\n : html,\n tags: [\n {\n tag: \"base\",\n attrs: {\n href: generateEmptyShell ? \"%%APPSHELL_BASE%%\" : publicPath\n },\n injectTo: \"head-prepend\"\n }\n ]\n })\n }\n };\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import type { PluginOption } from "vite";
2
+ export default function generateBashScript(externalImportMap: boolean, inlineConfig: boolean): PluginOption;
3
+ //# sourceMappingURL=vite-generate-bash-script-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-generate-bash-script-plugin.d.ts","sourceRoot":"","sources":["../src/vite-generate-bash-script-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,MAAM,CAAC;AAIzD,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,iBAAiB,EAAE,OAAO,EAC1B,YAAY,EAAE,OAAO,GACpB,YAAY,CAuId"}
@@ -0,0 +1,122 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import SHARED_DEPENDENCIES from "./shared-dependencies.js";
4
+ export default function generateBashScript(externalImportMap, inlineConfig) {
5
+ let config;
6
+ let targetDir;
7
+ return {
8
+ name: "vite-plugin-generate-bash-script",
9
+ apply: "build",
10
+ configResolved(resolvedConfig) {
11
+ config = resolvedConfig;
12
+ targetDir = path.resolve(resolvedConfig.root, "scripts");
13
+ if (!targetDir) {
14
+ throw new Error("Please set outputPath, so we can know where to place the bash script file");
15
+ }
16
+ // create the targetDir if it does not exist
17
+ if (!fs.existsSync(targetDir)) {
18
+ fs.mkdirSync(targetDir, { recursive: true });
19
+ }
20
+ },
21
+ closeBundle() {
22
+ if (config.command === "serve") {
23
+ return;
24
+ }
25
+ const script = `#!/bin/bash
26
+ set -e
27
+ set -o pipefail
28
+
29
+ # This script is generated by @hitachivantara/app-shell-vite-plugin.
30
+ # Do not edit this file directly.
31
+
32
+ # This script will read the app-shell.config.json file and generate the importmap.
33
+
34
+ ${externalImportMap
35
+ ? "# The script will generate the importmap.js file."
36
+ : "# The importmap will be inlined in the index.html file, by replacing the %%APPSHELL_IMPORTMAP%% placeholder."}
37
+ ${inlineConfig
38
+ ? "# The config file will be inlined in the index.html file, by replacing the %%APPSHELL_CONFIG%% placeholder."
39
+ : "# The config will be saved as app-shell.config.json."}
40
+
41
+ # Check if the index.html file exists in the current directory, otherwise exit:
42
+ if [ ! -f index.html ]; then
43
+ echo "index.html file not found. Are you running this script in the correct directory?" >&2
44
+ exit 1
45
+ fi
46
+
47
+ CONFIG_FILE=\${1:-app-shell.config.json}
48
+
49
+ # Check if the config file exists, otherwise exit:
50
+ if [ ! -f "\${CONFIG_FILE}" ]; then
51
+ echo "Config file not found: \${CONFIG_FILE}" >&2
52
+ exit 1
53
+ fi
54
+
55
+ SCRIPT_DIR="$(cd "$(dirname "\${BASH_SOURCE[0]}")" && pwd)"
56
+ INDEX_HTML_ORIGINAL="\${SCRIPT_DIR}/index.html.original"
57
+
58
+ # If the index.html doesn't contain any %%APPSHELL_*%% placeholders, copy the index.html.original at the script location:
59
+ if ! grep -q "%%APPSHELL_" index.html; then
60
+ if [ -f "\${INDEX_HTML_ORIGINAL}" ]; then
61
+ cp "\${INDEX_HTML_ORIGINAL}" index.html
62
+ fi
63
+ else
64
+ # Backup the index.html file to index.html.original, in the current script folder:
65
+ cp index.html "\${INDEX_HTML_ORIGINAL}"
66
+ fi
67
+
68
+ # Reading the app-shell.config.json file:
69
+ CONFIG=$(cat "\${CONFIG_FILE}")
70
+
71
+ # Getting the title from the config "name" property:
72
+ TITLE=$(echo "\${CONFIG}" | jq -r '.name')
73
+ if [ -z "\${TITLE}" ] || [ "\${TITLE}" = "null" ] || [ "\${TITLE}" = "undefined" ]; then
74
+ TITLE="Hitachi Vantara"
75
+ fi
76
+
77
+ # Replacing the title placeholder in the index.html file:
78
+ sed -i.bak "s/%%APPSHELL_TITLE%%/\${TITLE//\\//\\\\/}/g" index.html && rm index.html.bak
79
+
80
+ # Search for "@self" app and get its baseUrl:
81
+ SELF_BASEURL=$(echo "\${CONFIG}" | jq -r '.apps[] | select(.id == "@self") | .baseUrl')
82
+ if [ -z "\${SELF_BASEURL}" ] || [ "\${SELF_BASEURL}" = "null" ] || [ "\${SELF_BASEURL}" = "undefined" ]; then
83
+ SELF_BASEURL="/"
84
+ fi
85
+
86
+ # Replace the base placeholder in the index.html file:
87
+ sed -i.bak "s/%%APPSHELL_BASE%%/\${SELF_BASEURL//\\//\\\\/}/g" index.html && rm index.html.bak
88
+
89
+ # Generating the importmap:
90
+ # for each app, we add a mapping from the app id to the app url
91
+ IMPORTMAP="{\\"imports\\":{${SHARED_DEPENDENCIES.map(({ moduleId, bundle }) => `\\"${moduleId}\\":\\"./bundles/${bundle}\\",`).join("")}"
92
+ while IFS= read -r line; do
93
+ id=$(echo "$line" | jq -r '.id')
94
+ baseUrl=$(echo "$line" | jq -r '.baseUrl')
95
+ IMPORTMAP="\${IMPORTMAP}\\"\${id}/\\":\\"\${baseUrl}\\","
96
+ done < <(echo "\${CONFIG}" | jq -c '.apps[]')
97
+ IMPORTMAP="\${IMPORTMAP%?}}}"
98
+
99
+ ${externalImportMap
100
+ ? `# Generating the importmap.js file:
101
+ echo "const im = document.createElement('script'); im.type = 'importmap'; im.textContent = \\\`\${IMPORTMAP}\\\`; document.currentScript.after(im);" >importmap.js`
102
+ : `# Inlining the importmap in the index.html file:
103
+ sed -i.bak "s/%%APPSHELL_IMPORTMAP%%/\${IMPORTMAP//\\//\\\\/}/g" index.html && rm index.html.bak`}
104
+
105
+ ${inlineConfig
106
+ ? `# Inlining the config in the index.html file:
107
+ CONFIG=$(echo "\${CONFIG}" | tr -d '\\n')
108
+ sed -i.bak "s/%%APPSHELL_CONFIG%%/\${CONFIG//\\//\\\\/}/g" index.html && rm index.html.bak
109
+
110
+ # Removing the config file, just in case:
111
+ rm -f app-shell.config.json`
112
+ : `if [ "\${CONFIG_FILE}" != "app-shell.config.json" ]; then
113
+ echo "\${CONFIG}" >app-shell.config.json
114
+ fi`}
115
+ `;
116
+ fs.writeFileSync(path.join(targetDir, "app-shell.sh"), script, {
117
+ encoding: "utf-8"
118
+ });
119
+ }
120
+ };
121
+ }
122
+ //# sourceMappingURL=vite-generate-bash-script-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-generate-bash-script-plugin.js","sourceRoot":"","sources":["../src/vite-generate-bash-script-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAIxB,OAAO,mBAAmB,MAAM,0BAA0B,CAAC;AAE3D,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,iBAA0B,EAC1B,YAAqB;IAErB,IAAI,MAAsB,CAAC;IAC3B,IAAI,SAA6B,CAAC;IAElC,OAAO;QACL,IAAI,EAAE,kCAAkC;QACxC,KAAK,EAAE,OAAO;QAEd,cAAc,CAAC,cAAc;YAC3B,MAAM,GAAG,cAAc,CAAC;YACxB,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;YAEzD,IAAI,CAAC,SAAS,EAAE;gBACd,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;aACH;YAED,4CAA4C;YAC5C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;gBAC7B,EAAE,CAAC,SAAS,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;aAC9C;QACH,CAAC;QACD,WAAW;YACT,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,EAAE;gBAC9B,OAAO;aACR;YAED,MAAM,MAAM,GAAG;;;;;;;;;EAUnB,iBAAiB;gBACf,CAAC,CAAC,mDAAmD;gBACrD,CAAC,CAAC,8GACN;EAEE,YAAY;gBACV,CAAC,CAAC,6GAA6G;gBAC/G,CAAC,CAAC,sDACN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAoD6B,mBAAmB,CAAC,GAAG,CAC5C,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,QAAQ,oBAAoB,MAAM,MAAM,CACzE,CAAC,IAAI,CAAC,EAAE,CAAC;;;;;;;;EASd,iBAAiB;gBACf,CAAC,CAAC;mKAC6J;gBAC/J,CAAC,CAAC;iGAEN;;EAGE,YAAY;gBACV,CAAC,CAAC;;;;;4BAKsB;gBACxB,CAAC,CAAC;;GAGN;CACC,CAAC;YAEI,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,SAAU,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE;gBAC9D,QAAQ,EAAE,OAAO;aAClB,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport type { PluginOption, ResolvedConfig } from \"vite\";\n\nimport SHARED_DEPENDENCIES from \"./shared-dependencies.js\";\n\nexport default function generateBashScript(\n externalImportMap: boolean,\n inlineConfig: boolean\n): PluginOption {\n let config: ResolvedConfig;\n let targetDir: string | undefined;\n\n return {\n name: \"vite-plugin-generate-bash-script\",\n apply: \"build\",\n\n configResolved(resolvedConfig) {\n config = resolvedConfig;\n targetDir = path.resolve(resolvedConfig.root, \"scripts\");\n\n if (!targetDir) {\n throw new Error(\n \"Please set outputPath, so we can know where to place the bash script 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 closeBundle() {\n if (config.command === \"serve\") {\n return;\n }\n\n const script = `#!/bin/bash\nset -e\nset -o pipefail\n\n# This script is generated by @hitachivantara/app-shell-vite-plugin.\n# Do not edit this file directly.\n\n# This script will read the app-shell.config.json file and generate the importmap.\n\n${\n externalImportMap\n ? \"# The script will generate the importmap.js file.\"\n : \"# The importmap will be inlined in the index.html file, by replacing the %%APPSHELL_IMPORTMAP%% placeholder.\"\n}\n${\n inlineConfig\n ? \"# The config file will be inlined in the index.html file, by replacing the %%APPSHELL_CONFIG%% placeholder.\"\n : \"# The config will be saved as app-shell.config.json.\"\n}\n\n# Check if the index.html file exists in the current directory, otherwise exit:\nif [ ! -f index.html ]; then\n echo \"index.html file not found. Are you running this script in the correct directory?\" >&2\n exit 1\nfi\n\nCONFIG_FILE=\\${1:-app-shell.config.json}\n\n# Check if the config file exists, otherwise exit:\nif [ ! -f \"\\${CONFIG_FILE}\" ]; then\n echo \"Config file not found: \\${CONFIG_FILE}\" >&2\n exit 1\nfi\n\nSCRIPT_DIR=\"$(cd \"$(dirname \"\\${BASH_SOURCE[0]}\")\" && pwd)\"\nINDEX_HTML_ORIGINAL=\"\\${SCRIPT_DIR}/index.html.original\"\n\n# If the index.html doesn't contain any %%APPSHELL_*%% placeholders, copy the index.html.original at the script location:\nif ! grep -q \"%%APPSHELL_\" index.html; then\n if [ -f \"\\${INDEX_HTML_ORIGINAL}\" ]; then\n cp \"\\${INDEX_HTML_ORIGINAL}\" index.html\n fi\nelse\n # Backup the index.html file to index.html.original, in the current script folder:\n cp index.html \"\\${INDEX_HTML_ORIGINAL}\"\nfi\n\n# Reading the app-shell.config.json file:\nCONFIG=$(cat \"\\${CONFIG_FILE}\")\n\n# Getting the title from the config \"name\" property:\nTITLE=$(echo \"\\${CONFIG}\" | jq -r '.name')\nif [ -z \"\\${TITLE}\" ] || [ \"\\${TITLE}\" = \"null\" ] || [ \"\\${TITLE}\" = \"undefined\" ]; then\n TITLE=\"Hitachi Vantara\"\nfi\n\n# Replacing the title placeholder in the index.html file:\nsed -i.bak \"s/%%APPSHELL_TITLE%%/\\${TITLE//\\\\//\\\\\\\\/}/g\" index.html && rm index.html.bak\n\n# Search for \"@self\" app and get its baseUrl:\nSELF_BASEURL=$(echo \"\\${CONFIG}\" | jq -r '.apps[] | select(.id == \"@self\") | .baseUrl')\nif [ -z \"\\${SELF_BASEURL}\" ] || [ \"\\${SELF_BASEURL}\" = \"null\" ] || [ \"\\${SELF_BASEURL}\" = \"undefined\" ]; then\n SELF_BASEURL=\"/\"\nfi\n\n# Replace the base placeholder in the index.html file:\nsed -i.bak \"s/%%APPSHELL_BASE%%/\\${SELF_BASEURL//\\\\//\\\\\\\\/}/g\" index.html && rm index.html.bak\n\n# Generating the importmap:\n# for each app, we add a mapping from the app id to the app url\nIMPORTMAP=\"{\\\\\"imports\\\\\":{${SHARED_DEPENDENCIES.map(\n ({ moduleId, bundle }) => `\\\\\"${moduleId}\\\\\":\\\\\"./bundles/${bundle}\\\\\",`\n ).join(\"\")}\"\nwhile IFS= read -r line; do\n id=$(echo \"$line\" | jq -r '.id')\n baseUrl=$(echo \"$line\" | jq -r '.baseUrl')\n IMPORTMAP=\"\\${IMPORTMAP}\\\\\"\\${id}/\\\\\":\\\\\"\\${baseUrl}\\\\\",\"\ndone < <(echo \"\\${CONFIG}\" | jq -c '.apps[]')\nIMPORTMAP=\"\\${IMPORTMAP%?}}}\"\n\n${\n externalImportMap\n ? `# Generating the importmap.js file:\necho \"const im = document.createElement('script'); im.type = 'importmap'; im.textContent = \\\\\\`\\${IMPORTMAP}\\\\\\`; document.currentScript.after(im);\" >importmap.js`\n : `# Inlining the importmap in the index.html file:\nsed -i.bak \"s/%%APPSHELL_IMPORTMAP%%/\\${IMPORTMAP//\\\\//\\\\\\\\/}/g\" index.html && rm index.html.bak`\n}\n\n${\n inlineConfig\n ? `# Inlining the config in the index.html file:\nCONFIG=$(echo \"\\${CONFIG}\" | tr -d '\\\\n')\nsed -i.bak \"s/%%APPSHELL_CONFIG%%/\\${CONFIG//\\\\//\\\\\\\\/}/g\" index.html && rm index.html.bak\n\n# Removing the config file, just in case:\nrm -f app-shell.config.json`\n : `if [ \"\\${CONFIG_FILE}\" != \"app-shell.config.json\" ]; then\n echo \"\\${CONFIG}\" >app-shell.config.json\nfi`\n}\n`;\n\n fs.writeFileSync(path.join(targetDir!, \"app-shell.sh\"), script, {\n encoding: \"utf-8\"\n });\n }\n };\n}\n"]}
@@ -1,8 +1,8 @@
1
- import { PluginOption } from "vite";
1
+ import type { PluginOption } from "vite";
2
2
  /**
3
3
  * Generate and injects the importmap tag into index.html
4
4
  * @param importmapElements The importmap elements to be included
5
5
  * @param sharedDependencies The shared packages (other than application bundles)
6
6
  */
7
- export default function generateImportmap(importmapElements: Record<string, string>, sharedDependencies: string[], externalImportMap?: boolean): PluginOption;
7
+ export default function generateImportmap(importmapElements: Record<string, string>, sharedDependencies: string[], externalImportMap?: boolean, placeholderEntryPoint?: boolean): PluginOption;
8
8
  //# sourceMappingURL=vite-importmap-plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-importmap-plugin.d.ts","sourceRoot":"","sources":["../src/vite-importmap-plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAiCpC;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,kBAAkB,EAAE,MAAM,EAAE,EAC5B,iBAAiB,UAAQ,GACxB,YAAY,CAiLd"}
1
+ {"version":3,"file":"vite-importmap-plugin.d.ts","sourceRoot":"","sources":["../src/vite-importmap-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AA0CzC;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACzC,kBAAkB,EAAE,MAAM,EAAE,EAC5B,iBAAiB,UAAQ,EACzB,qBAAqB,UAAQ,GAC5B,YAAY,CAmLd"}
@@ -16,7 +16,16 @@ function replaceIdPrefix(keys) {
16
16
  id,
17
17
  external: true
18
18
  }
19
- : undefined
19
+ : undefined,
20
+ // Avoid the warning: The following dependencies are imported but could not be resolved: [dependency] (imported by [sourceFile])
21
+ load: (id) => {
22
+ if (keys.includes(id)) {
23
+ // Vite will try to resolve the modules even when externalized
24
+ // In order to suppress the warning, a stub module is returned
25
+ return "export default {};";
26
+ }
27
+ return undefined;
28
+ }
20
29
  };
21
30
  }
22
31
  /**
@@ -24,7 +33,7 @@ function replaceIdPrefix(keys) {
24
33
  * @param importmapElements The importmap elements to be included
25
34
  * @param sharedDependencies The shared packages (other than application bundles)
26
35
  */
27
- export default function generateImportmap(importmapElements, sharedDependencies, externalImportMap = false) {
36
+ export default function generateImportmap(importmapElements, sharedDependencies, externalImportMap = false, placeholderEntryPoint = false) {
28
37
  const keys = Object.keys(importmapElements);
29
38
  const devKeys = keys.filter(key => !sharedDependencies.some(lib => lib.startsWith(key)));
30
39
  let devMode = false;
@@ -111,7 +120,7 @@ document.currentScript.after(im);
111
120
  * @param bundle bundles information
112
121
  */
113
122
  async generateBundle(options) {
114
- if (!externalImportMap) {
123
+ if (!externalImportMap || placeholderEntryPoint) {
115
124
  return;
116
125
  }
117
126
  // obtain the directory (dist) where the new config file will be placed
@@ -154,7 +163,9 @@ document.currentScript.after(im);
154
163
  tag: "script",
155
164
  attrs: { type: "importmap" },
156
165
  injectTo: "head-prepend",
157
- children: importmapString
166
+ children: placeholderEntryPoint
167
+ ? "%%APPSHELL_IMPORTMAP%%"
168
+ : importmapString
158
169
  }
159
170
  ]
160
171
  })
@@ -1 +1 @@
1
- {"version":3,"file":"vite-importmap-plugin.js","sourceRoot":"","sources":["../src/vite-importmap-plugin.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,MAAM,SAAS,GAAG,OAAO,CAAC;AAE1B,SAAS,eAAe,CAAC,IAAyB;IAChD,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAE/D,OAAO;QACL,IAAI,EAAE,wCAAwC;QAC9C,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,OAAO;QAEd,6EAA6E;QAC7E,SAAS,EAAE,IAAI,CAAC,EAAE,CAChB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;QAE1D,wCAAwC;QACxC,SAAS,EAAE,CAAC,EAAU,EAAE,EAAE,CACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CACd,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAC5D;YACC,CAAC,CAAC;gBACE,EAAE;gBACF,QAAQ,EAAE,IAAI;aACf;YACH,CAAC,CAAC,SAAS;KAChB,CAAC;AACJ,CAA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AE,CAAC,aAAa,CACd,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,cAAc,CAAC,EACvC,eAAe,CAChB,CAAC;YACJ,CAAC;YAED,kEAAkE;YAClE,kBAAkB,EAAE;gBAClB,OAAO,EAAE,MAAM;gBACf,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;oBAClB,IAAI;oBACJ,IAAI,EAAE;wBACJ;4BACE,GAAG,EAAE,QAAQ;4BACb,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,8BAA8B,EAAE;4BAC3D,QAAQ,EAAE,cAAc;yBACzB;wBACD,iBAAiB;4BACf,CAAC,CAAC;gCACE,GAAG,EAAE,QAAQ;gCACb,KAAK,EAAE,EAAE,GAAG,EAAE,gBAAgB,EAAE;gCAChC,QAAQ,EAAE,cAAc;6BACzB;4BACH,CAAC,CAAC;gCACE,GAAG,EAAE,QAAQ;gCACb,KAAK,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE;gCAC5B,QAAQ,EAAE,cAAc;gCACxB,QAAQ,EAAE,eAAe;6BAC1B;qBACN;iBACF,CAAC;aACH;SACF;QACD,iBAAiB;YACf,CAAC,CAAC,OAAO,CAAC;gBACN,eAAe,EAAE,eAAe;aACjC,CAAC;YACJ,CAAC,CAAC,KAAK;KACV,CAAC;AACJ,CAAC","sourcesContent":["import { NormalizedOutputOptions } from \"rollup\";\nimport { PluginOption } from \"vite\";\n\nimport fs from \"fs\";\nimport path from \"path\";\nimport virtual from \"@rollup/plugin-virtual\";\n\nconst ID_PREFIX = `/@id/`;\n\nfunction replaceIdPrefix(keys: (string | RegExp)[]): PluginOption {\n const reg = new RegExp(`${ID_PREFIX}(${keys.join(\"|\")})`, \"g\");\n\n return {\n name: \"vite-plugin-importmap-replace-idprefix\",\n enforce: \"pre\",\n apply: \"serve\",\n\n // while in dev, we need to prevent 'vite:import-analysis' on runtime modules\n transform: code =>\n reg.test(code) ? code.replace(reg, (m, s1) => s1) : code,\n\n // and to say its resolved (as external)\n resolveId: (id: string) =>\n keys.some(key =>\n typeof key === \"string\" ? id.startsWith(key) : key.test(id)\n )\n ? {\n id,\n external: true\n }\n : undefined\n };\n}\n\n/**\n * Generate and injects the importmap tag into index.html\n * @param importmapElements The importmap elements to be included\n * @param sharedDependencies The shared packages (other than application bundles)\n */\nexport default function generateImportmap(\n importmapElements: Record<string, string>,\n sharedDependencies: string[],\n externalImportMap = false\n): PluginOption {\n const keys = Object.keys(importmapElements);\n const devKeys = keys.filter(\n key => !sharedDependencies.some(lib => lib.startsWith(key))\n );\n\n let devMode = false;\n\n const importmapString = JSON.stringify(\n { imports: importmapElements },\n null,\n 2\n );\n\n const importmapScript = `const im = document.createElement('script');\nim.type = 'importmap';\nim.textContent = \\`${importmapString}\\`;\ndocument.currentScript.after(im);\n`;\n\n return [\n {\n name: \"vite-plugin-importmap\",\n enforce: \"pre\",\n\n // don't optimize / pre-transform deps that are in the importmap\n // except for react and react-dom when in dev mode\n config(config, { command }) {\n devMode = command !== \"build\";\n\n // vite docs says we can mutate the passed-in config directly\n // assigning to a new variable just to avoid the eslint warning\n const returnValue = config;\n\n // make sure optimizeDeps is defined\n returnValue.optimizeDeps = returnValue.optimizeDeps ?? {};\n\n returnValue.optimizeDeps.exclude = [\n ...(config.optimizeDeps?.exclude ?? []),\n ...(devMode ? devKeys : keys)\n ];\n\n if (devMode) {\n return;\n }\n\n // mark the modules referenced in the importmap as external\n const excludedModules = keys.map(key => {\n if (key.endsWith(\"/\")) {\n return new RegExp(`^${key}.*`);\n }\n\n return key;\n });\n\n console.info(\"Shared packages marked as external: \", excludedModules);\n\n // make sure build's rollupOptions is defined\n returnValue.build = returnValue.build ?? {};\n returnValue.build.rollupOptions = returnValue.build.rollupOptions ?? {};\n returnValue.build.rollupOptions.external =\n returnValue.build.rollupOptions.external ?? [];\n\n if (typeof returnValue.build.rollupOptions.external === \"function\") {\n // in case the developer has defined a custom external function\n // we wrap it and check our excluded modules first and call the original function if needed\n const originalExternal = returnValue.build.rollupOptions.external;\n\n returnValue.build.rollupOptions.external = (id, ...args) => {\n if (excludedModules.some(m => typeof m === id)) {\n return true;\n }\n\n return originalExternal(id, ...args);\n };\n } else {\n // otherwise we just add our excluded modules to the list supplied by the developer\n const externalModules: (string | RegExp)[] = [];\n\n if (Array.isArray(returnValue.build.rollupOptions.external)) {\n externalModules.push(...returnValue.build.rollupOptions.external);\n } else {\n externalModules.push(returnValue.build.rollupOptions.external);\n }\n\n externalModules.push(...excludedModules);\n\n returnValue.build.rollupOptions.external = externalModules;\n }\n },\n\n // while in dev, we need to prevent 'vite:import-analysis' on runtime modules\n // and also to say they're resolved (as external)\n // (it will still output an error in the console, but it won't break)\n // known issue: https://github.com/vitejs/vite/issues/11633\n configResolved(resolvedConfig) {\n if (!devMode) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore an hack: we want to add the plugin only after the config is resolved\n resolvedConfig.plugins.push(replaceIdPrefix(devKeys));\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(options: NormalizedOutputOptions) {\n if (!externalImportMap) {\n return;\n }\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 // support for external import maps isn't yet available (https://github.com/WICG/import-maps/issues/235)\n // workaround: https://github.com/WICG/import-maps/issues/235#issuecomment-1002340944\n fs.writeFileSync(\n path.resolve(targetDir, \"importmap.js\"),\n importmapScript\n );\n },\n\n // inject the importmap script and also the es-module-shims script\n transformIndexHtml: {\n enforce: \"post\",\n transform: html => ({\n html,\n tags: [\n {\n tag: \"script\",\n attrs: { async: true, src: \"./bundles/es-module-shims.js\" },\n injectTo: \"head-prepend\"\n },\n externalImportMap\n ? {\n tag: \"script\",\n attrs: { src: \"./importmap.js\" },\n injectTo: \"head-prepend\"\n }\n : {\n tag: \"script\",\n attrs: { type: \"importmap\" },\n injectTo: \"head-prepend\",\n children: importmapString\n }\n ]\n })\n }\n },\n externalImportMap\n ? virtual({\n \"/importmap.js\": importmapScript\n })\n : false\n ];\n}\n"]}
1
+ {"version":3,"file":"vite-importmap-plugin.js","sourceRoot":"","sources":["../src/vite-importmap-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AAKxB,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,MAAM,SAAS,GAAG,OAAO,CAAC;AAE1B,SAAS,eAAe,CAAC,IAAyB;IAChD,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,GAAG,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IAE/D,OAAO;QACL,IAAI,EAAE,wCAAwC;QAC9C,OAAO,EAAE,KAAK;QACd,KAAK,EAAE,OAAO;QAEd,6EAA6E;QAC7E,SAAS,EAAE,IAAI,CAAC,EAAE,CAChB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI;QAE1D,wCAAwC;QACxC,SAAS,EAAE,CAAC,EAAU,EAAE,EAAE,CACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CACd,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,U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C,CAAC,OAAO,CAAC;gBACN,eAAe,EAAE,eAAe;aACjC,CAAC;YACJ,CAAC,CAAC,KAAK;KACV,CAAC;AACJ,CAAC","sourcesContent":["import fs from \"fs\";\nimport path from \"path\";\n\nimport type { NormalizedOutputOptions } from \"rollup\";\nimport type { PluginOption } from \"vite\";\n\nimport virtual from \"@rollup/plugin-virtual\";\n\nconst ID_PREFIX = `/@id/`;\n\nfunction replaceIdPrefix(keys: (string | RegExp)[]): PluginOption {\n const reg = new RegExp(`${ID_PREFIX}(${keys.join(\"|\")})`, \"g\");\n\n return {\n name: \"vite-plugin-importmap-replace-idprefix\",\n enforce: \"pre\",\n apply: \"serve\",\n\n // while in dev, we need to prevent 'vite:import-analysis' on runtime modules\n transform: code =>\n reg.test(code) ? code.replace(reg, (m, s1) => s1) : code,\n\n // and to say its resolved (as external)\n resolveId: (id: string) =>\n keys.some(key =>\n typeof key === \"string\" ? id.startsWith(key) : key.test(id)\n )\n ? {\n id,\n external: true\n }\n : undefined,\n\n // Avoid the warning: The following dependencies are imported but could not be resolved: [dependency] (imported by [sourceFile])\n load: (id: string) => {\n if (keys.includes(id)) {\n // Vite will try to resolve the modules even when externalized\n // In order to suppress the warning, a stub module is returned\n return \"export default {};\";\n }\n\n return undefined;\n }\n };\n}\n\n/**\n * Generate and injects the importmap tag into index.html\n * @param importmapElements The importmap elements to be included\n * @param sharedDependencies The shared packages (other than application bundles)\n */\nexport default function generateImportmap(\n importmapElements: Record<string, string>,\n sharedDependencies: string[],\n externalImportMap = false,\n placeholderEntryPoint = false\n): PluginOption {\n const keys = Object.keys(importmapElements);\n const devKeys = keys.filter(\n key => !sharedDependencies.some(lib => lib.startsWith(key))\n );\n\n let devMode = false;\n\n const importmapString = JSON.stringify(\n { imports: importmapElements },\n null,\n 2\n );\n\n const importmapScript = `const im = document.createElement('script');\nim.type = 'importmap';\nim.textContent = \\`${importmapString}\\`;\ndocument.currentScript.after(im);\n`;\n\n return [\n {\n name: \"vite-plugin-importmap\",\n enforce: \"pre\",\n\n // don't optimize / pre-transform deps that are in the importmap\n // except for react and react-dom when in dev mode\n config(config, { command }) {\n devMode = command !== \"build\";\n\n // vite docs says we can mutate the passed-in config directly\n // assigning to a new variable just to avoid the eslint warning\n const returnValue = config;\n\n // make sure optimizeDeps is defined\n returnValue.optimizeDeps = returnValue.optimizeDeps ?? {};\n\n returnValue.optimizeDeps.exclude = [\n ...(config.optimizeDeps?.exclude ?? []),\n ...(devMode ? devKeys : keys)\n ];\n\n if (devMode) {\n return;\n }\n\n // mark the modules referenced in the importmap as external\n const excludedModules = keys.map(key => {\n if (key.endsWith(\"/\")) {\n return new RegExp(`^${key}.*`);\n }\n\n return key;\n });\n\n console.info(\"Shared packages marked as external: \", excludedModules);\n\n // make sure build's rollupOptions is defined\n returnValue.build = returnValue.build ?? {};\n returnValue.build.rollupOptions = returnValue.build.rollupOptions ?? {};\n returnValue.build.rollupOptions.external =\n returnValue.build.rollupOptions.external ?? [];\n\n if (typeof returnValue.build.rollupOptions.external === \"function\") {\n // in case the developer has defined a custom external function\n // we wrap it and check our excluded modules first and call the original function if needed\n const originalExternal = returnValue.build.rollupOptions.external;\n\n returnValue.build.rollupOptions.external = (id, ...args) => {\n if (excludedModules.some(m => typeof m === id)) {\n return true;\n }\n\n return originalExternal(id, ...args);\n };\n } else {\n // otherwise we just add our excluded modules to the list supplied by the developer\n const externalModules: (string | RegExp)[] = [];\n\n if (Array.isArray(returnValue.build.rollupOptions.external)) {\n externalModules.push(...returnValue.build.rollupOptions.external);\n } else {\n externalModules.push(returnValue.build.rollupOptions.external);\n }\n\n externalModules.push(...excludedModules);\n\n returnValue.build.rollupOptions.external = externalModules;\n }\n },\n\n // while in dev, we need to prevent 'vite:import-analysis' on runtime modules\n // and also to say they're resolved (as external)\n // (it will still output an error in the console, but it won't break)\n // known issue: https://github.com/vitejs/vite/issues/11633\n configResolved(resolvedConfig) {\n if (!devMode) {\n return;\n }\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore an hack: we want to add the plugin only after the config is resolved\n resolvedConfig.plugins.push(replaceIdPrefix(devKeys));\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(options: NormalizedOutputOptions) {\n if (!externalImportMap || placeholderEntryPoint) {\n return;\n }\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 // support for external import maps isn't yet available (https://github.com/WICG/import-maps/issues/235)\n // workaround: https://github.com/WICG/import-maps/issues/235#issuecomment-1002340944\n fs.writeFileSync(\n path.resolve(targetDir, \"importmap.js\"),\n importmapScript\n );\n },\n\n // inject the importmap script and also the es-module-shims script\n transformIndexHtml: {\n enforce: \"post\",\n transform: html => ({\n html,\n tags: [\n {\n tag: \"script\",\n attrs: { async: true, src: \"./bundles/es-module-shims.js\" },\n injectTo: \"head-prepend\"\n },\n externalImportMap\n ? {\n tag: \"script\",\n attrs: { src: \"./importmap.js\" },\n injectTo: \"head-prepend\"\n }\n : {\n tag: \"script\",\n attrs: { type: \"importmap\" },\n injectTo: \"head-prepend\",\n children: placeholderEntryPoint\n ? \"%%APPSHELL_IMPORTMAP%%\"\n : importmapString\n }\n ]\n })\n }\n },\n externalImportMap\n ? virtual({\n \"/importmap.js\": importmapScript\n })\n : false\n ];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"vite-metadata-plugin.d.ts","sourceRoot":"","sources":["../src/vite-metadata-plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AASzC;;;;GAIG;AACH,QAAA,MAAM,cAAc,QAAO,YA8B1B,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"vite-metadata-plugin.d.ts","sourceRoot":"","sources":["../src/vite-metadata-plugin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAUzC;;;;GAIG;AACH,QAAA,MAAM,cAAc,QAAO,YA8B1B,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"vite-metadata-plugin.js","sourceRoot":"","sources":["../src/vite-metadata-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,cAAc,GAAG,CAAC,eAAuB,EAAU,EAAE;IACzD,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9C,OAAO,aAAa,CAAC,OAAO,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,cAAc,GAAG,GAAiB,EAAE;IACxC,MAAM,eAAe,GAAG,cAAc,CACpC,aAAa,CAAC,wCAAwC,CAAC,CACxD,CAAC;IAEF,MAAM,yBAAyB,GAAG,cAAc,CAC9C,aAAa,CAAC,oDAAoD,CAAC,CACpE,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,kBAAkB;YAChB,OAAO;gBACL;oBACE,GAAG,EAAE,MAAM;oBACX,KAAK,EAAE;wBACL,IAAI,EAAE,mBAAmB;wBACzB,OAAO,EAAE,eAAe;qBACzB;iBACF;gBACD;oBACE,GAAG,EAAE,MAAM;oBACX,KAAK,EAAE;wBACL,IAAI,EAAE,+BAA+B;wBACrC,OAAO,EAAE,yBAAyB;qBACnC;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import fs from \"fs\";\nimport type { PluginOption } from \"vite\";\nimport { resolveModule } from \"./nodeModule.js\";\n\nconst extractVersion = (packageJsonFile: string): string => {\n const packageJson = fs.readFileSync(packageJsonFile, \"utf8\");\n const packageObject = JSON.parse(packageJson);\n return packageObject.version;\n};\n\n/**\n * This plugin injects metadata into the index.html file.\n * The metadata is used to help any troubleshoot activity by referencing\n * the version of the app-shell-vite-plugin and app-shell packages used by the app.\n */\nconst injectMetadata = (): PluginOption => {\n const appShellVersion = extractVersion(\n resolveModule(\"@hitachivantara/app-shell/package.json\")\n );\n\n const appShellVitePluginVersion = extractVersion(\n resolveModule(\"@hitachivantara/app-shell-vite-plugin/package.json\")\n );\n\n return {\n name: \"vite-metadata-plugin\",\n transformIndexHtml() {\n return [\n {\n tag: \"meta\",\n attrs: {\n name: \"app-shell-version\",\n content: appShellVersion\n }\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"app-shell-vite-plugin-version\",\n content: appShellVitePluginVersion\n }\n }\n ];\n }\n };\n};\n\nexport default injectMetadata;\n"]}
1
+ {"version":3,"file":"vite-metadata-plugin.js","sourceRoot":"","sources":["../src/vite-metadata-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AAIpB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,cAAc,GAAG,CAAC,eAAuB,EAAU,EAAE;IACzD,MAAM,WAAW,GAAG,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,CAAC;IAC7D,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9C,OAAO,aAAa,CAAC,OAAO,CAAC;AAC/B,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,cAAc,GAAG,GAAiB,EAAE;IACxC,MAAM,eAAe,GAAG,cAAc,CACpC,aAAa,CAAC,wCAAwC,CAAC,CACxD,CAAC;IAEF,MAAM,yBAAyB,GAAG,cAAc,CAC9C,aAAa,CAAC,oDAAoD,CAAC,CACpE,CAAC;IAEF,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,kBAAkB;YAChB,OAAO;gBACL;oBACE,GAAG,EAAE,MAAM;oBACX,KAAK,EAAE;wBACL,IAAI,EAAE,mBAAmB;wBACzB,OAAO,EAAE,eAAe;qBACzB;iBACF;gBACD;oBACE,GAAG,EAAE,MAAM;oBACX,KAAK,EAAE;wBACL,IAAI,EAAE,+BAA+B;wBACrC,OAAO,EAAE,yBAAyB;qBACnC;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import fs from \"fs\";\n\nimport type { PluginOption } from \"vite\";\n\nimport { resolveModule } from \"./nodeModule.js\";\n\nconst extractVersion = (packageJsonFile: string): string => {\n const packageJson = fs.readFileSync(packageJsonFile, \"utf8\");\n const packageObject = JSON.parse(packageJson);\n return packageObject.version;\n};\n\n/**\n * This plugin injects metadata into the index.html file.\n * The metadata is used to help any troubleshoot activity by referencing\n * the version of the app-shell-vite-plugin and app-shell packages used by the app.\n */\nconst injectMetadata = (): PluginOption => {\n const appShellVersion = extractVersion(\n resolveModule(\"@hitachivantara/app-shell/package.json\")\n );\n\n const appShellVitePluginVersion = extractVersion(\n resolveModule(\"@hitachivantara/app-shell-vite-plugin/package.json\")\n );\n\n return {\n name: \"vite-metadata-plugin\",\n transformIndexHtml() {\n return [\n {\n tag: \"meta\",\n attrs: {\n name: \"app-shell-version\",\n content: appShellVersion\n }\n },\n {\n tag: \"meta\",\n attrs: {\n name: \"app-shell-vite-plugin-version\",\n content: appShellVitePluginVersion\n }\n }\n ];\n }\n };\n};\n\nexport default injectMetadata;\n"]}
@@ -1,4 +1,5 @@
1
1
  import type { PluginOption } from "vite";
2
+ import { ConfigReplacement } from "./config-utils.js";
2
3
  export declare enum ApplicationBundleType {
3
4
  APP = "app",
4
5
  BUNDLE = "bundle"
@@ -6,7 +7,7 @@ export declare enum ApplicationBundleType {
6
7
  type ApplicationBundleTypeKey = `${ApplicationBundleType}`;
7
8
  export interface AppShellVitePluginOptions {
8
9
  /**
9
- * Project root directory. Most likely location of the vite config file.
10
+ * Project root directory. Most likely the location of the vite config file.
10
11
  *
11
12
  * @default process.cwd()
12
13
  */
@@ -15,13 +16,6 @@ export interface AppShellVitePluginOptions {
15
16
  * Execution mode.
16
17
  */
17
18
  mode?: string;
18
- /**
19
- * If true, the plugin will generate the importmap with an external js file instead of inline in the html.
20
- * The map will be saved at the root of the application destination dir and named as "importmap.js"
21
- *
22
- * @default false
23
- */
24
- externalImportMap?: boolean;
25
19
  /**
26
20
  * Type of application bundle being built. Can be "app" or "bundle".
27
21
  *
@@ -44,10 +38,7 @@ export interface AppShellVitePluginOptions {
44
38
  * "baseUrl": "@@USER_NOTIFICATIONS_URL@@"
45
39
  * }
46
40
  */
47
- configReplacements?: {
48
- token: string;
49
- value: string;
50
- }[];
41
+ configReplacements?: ConfigReplacement[];
51
42
  /**
52
43
  * The folder containing Views to be shared as Shared Modules. Defaults to "src/pages".
53
44
  *
@@ -62,9 +53,41 @@ export interface AppShellVitePluginOptions {
62
53
  autoViewsAndRoutes?: boolean;
63
54
  /**
64
55
  * If true, the plugin will try to automatically add the views to the menu.
65
- * This this only valid when running in dev mode and if the app-shell.config.json file does not contain any menu configuration already.
56
+ * This is only valid when running in dev mode and if the app-shell.config.json file does not contain any menu configuration already.
66
57
  */
67
58
  autoDevMenu?: boolean;
59
+ /**
60
+ * If true, the plugin will generate the importmap with an external js file instead of inline in the html.
61
+ * The map will be saved at the root of the application destination dir and named as "importmap.js".
62
+ *
63
+ * This option is not for general use. It is only intended to be used for easing the automated testing of the App Shell.
64
+ *
65
+ * @default false
66
+ * @private
67
+ */
68
+ externalImportMap?: boolean;
69
+ /**
70
+ * If true, the plugin will inline the app-shell.config.json file in a script tag of the index html.
71
+ *
72
+ * This option is not for general use. Its value will be automatically managed by the App Shell build process.
73
+ *
74
+ * @default false, true if generateEmptyShell is true
75
+ * @private
76
+ */
77
+ inlineConfig?: boolean;
78
+ /**
79
+ * If true, the config file is ignored, only the App Shell is built and the generated index.html will contain a placeholders
80
+ * for importmap (if externalImportMap is false), app shell config (if inlineConfig is true) and title.
81
+ *
82
+ * A bash script will also be added to the dist folder to replace the placeholders with the actual content,
83
+ * when provided with a concrete configuration.
84
+ *
85
+ * This option is not for general use. It is used for generating the App Shell container image.
86
+ *
87
+ * @default false
88
+ * @private
89
+ */
90
+ generateEmptyShell?: boolean;
68
91
  }
69
92
  /**
70
93
  * Vite plugin to support App Shell apps setup
@@ -1 +1 @@
1
- {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAc,MAAM,MAAM,CAAC;AAoXrD,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;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IAExD;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,OA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