@hitachivantara/app-shell-vite-plugin 0.14.0 → 0.15.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.
- package/dist/esm-externals/react-router-dom.production.min.js +7 -7
- package/dist/esm-externals/react-router-dom.production.min.js.map +1 -1
- package/dist/vite-generate-bash-script-plugin.js +1 -1
- package/dist/vite-generate-bash-script-plugin.js.map +1 -1
- package/dist/vite-plugin.d.ts.map +1 -1
- package/dist/vite-plugin.js +8 -0
- package/dist/vite-plugin.js.map +1 -1
- package/package.json +4 -3
|
@@ -94,7 +94,7 @@ while IFS= read -r line; do
|
|
|
94
94
|
baseUrl=$(echo "$line" | jq -r '.baseUrl')
|
|
95
95
|
IMPORTMAP="\${IMPORTMAP}\\"\${id}/\\":\\"\${baseUrl}\\","
|
|
96
96
|
done < <(echo "\${CONFIG}" | jq -c '.apps[]')
|
|
97
|
-
IMPORTMAP="\${IMPORTMAP%?}}}"
|
|
97
|
+
IMPORTMAP="\${IMPORTMAP%?}, \\"@hv/uikit-icons/\\": \\"./icons/\\" }}"
|
|
98
98
|
|
|
99
99
|
${externalImportMap
|
|
100
100
|
? `# Generating the importmap.js file:
|
|
@@ -1 +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
|
+
{"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%?}, \\\\\"@hv/uikit-icons/\\\\\": \\\\\"./icons/\\\\\" }}\"\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAWzC,OAAO,EACL,iBAAiB,EAGlB,MAAM,mBAAmB,CAAC;AAc3B,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;IAEd;;;;;;;OAOG;IACH,IAAI,CAAC,EAAE,wBAAwB,CAAC;IAEhC;;;;;;;;;;;;OAYG;IACH,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IAEzC;;;;OAIG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH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ACvB;;;;;;;;;;;OAWG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,GAAE,yBAA8B,EACpC,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GAC/B,YAAY,CAiJd;AAED,eAAe,kBAAkB,CAAC"}
|
package/dist/vite-plugin.js
CHANGED
|
@@ -55,6 +55,13 @@ export function appShellVitePlugin(opts = {}, env = {}) {
|
|
|
55
55
|
src: getModulePath("es-module-shims", "dist/*"),
|
|
56
56
|
dest: "bundles"
|
|
57
57
|
},
|
|
58
|
+
// copy the ui kit icons' sprites to the "icons" folder
|
|
59
|
+
{
|
|
60
|
+
src: [
|
|
61
|
+
getModulePath("@hitachivantara/uikit-react-icons", "dist/sprites/*.svg")
|
|
62
|
+
],
|
|
63
|
+
dest: "icons"
|
|
64
|
+
},
|
|
58
65
|
...(!devMode && buildEntryPoint
|
|
59
66
|
? [
|
|
60
67
|
{
|
|
@@ -82,6 +89,7 @@ export function appShellVitePlugin(opts = {}, env = {}) {
|
|
|
82
89
|
acc[dep.moduleId] = `./bundles/${dep.bundle}`;
|
|
83
90
|
return acc;
|
|
84
91
|
}, {}),
|
|
92
|
+
"@hv/uikit-icons/": "./icons/",
|
|
85
93
|
...appShellConfiguration?.apps?.reduce((acc, app) => {
|
|
86
94
|
if (app.id === "@self") {
|
|
87
95
|
acc[`${packageJson.name}/`] = app.baseUrl;
|
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;AAMzD,OAAO,iBAAiB,M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EACD,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,CACnB;QAED,gEAAgE;QAChE,mBAAmB,CACjB,qBAAqB,EACrB,IAAI,EACJ,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 type { PluginOption } from \"vite\";\n\nimport type { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\n\nimport generateImportmap 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 loadConfigFile\n} from \"./config-utils.js\";\nimport { resolveModule, getModulePath } 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 enum ApplicationBundleType {\n APP = \"app\",\n BUNDLE = \"bundle\"\n}\n\ntype ApplicationBundleTypeKey = `${ApplicationBundleType}`;\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?: 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?: 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 * This is 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 /**\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\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 inlineConfig = opts.generateEmptyShell ?? false,\n generateEmptyShell = false\n } = opts;\n\n console.info(`Vite running in mode: ${mode}`);\n\n const devMode = mode === ViteBuildMode.DEVELOPMENT;\n const buildEntryPoint = type !== ApplicationBundleType.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 if (!generateEmptyShell) {\n if (autoViewsAndRoutes) {\n applyAutomaticViewsAndRoutes(appShellConfiguration, root, viewsFolder);\n }\n\n if (devMode && autoDevMenu) {\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 ...(!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((acc, dep) => {\n acc[`/bundles/${dep.bundle}`] = dep.virtualSrc;\n return acc;\n }, {} as Record<string, string>)\n }),\n\n // generate the importmap for shared dependencies and for apps referenced in the config file\n generateImportmap(\n {\n ...SHARED_DEPENDENCIES.reduce((acc, dep) => {\n acc[dep.moduleId] = `./bundles/${dep.bundle}`;\n return acc;\n }, {} as Record<string, string>),\n\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 ...SHARED_DEPENDENCIES.map(dep => dep.moduleId),\n \"@self\",\n packageJson.name\n ],\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 ),\n\n // serve the app shell config file as json and watch for changes\n serveAppShellConfig(\n appShellConfiguration,\n root,\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;\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AAC;oBAC1C,IAAI,OAAO,EAAE;wBACX,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;qBACjC;iBACF;qBAAM;oBACL,GAAG,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;iBACjC;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAA4B,CAAC;SACjC,EACD;YACE,GAAG,mBAAmB,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,QAAQ,CAAC;YAC/C,OAAO;YACP,WAAW,CAAC,IAAI;SACjB,EACD,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,CACnB;QAED,gEAAgE;QAChE,mBAAmB,CACjB,qBAAqB,EACrB,IAAI,EACJ,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 type { PluginOption } from \"vite\";\n\nimport type { HvAppShellConfig } from \"@hitachivantara/app-shell-shared\";\n\nimport generateImportmap 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 loadConfigFile\n} from \"./config-utils.js\";\nimport { resolveModule, getModulePath } 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 enum ApplicationBundleType {\n APP = \"app\",\n BUNDLE = \"bundle\"\n}\n\ntype ApplicationBundleTypeKey = `${ApplicationBundleType}`;\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?: 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?: 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 * This is 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 /**\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\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 inlineConfig = opts.generateEmptyShell ?? false,\n generateEmptyShell = false\n } = opts;\n\n console.info(`Vite running in mode: ${mode}`);\n\n const devMode = mode === ViteBuildMode.DEVELOPMENT;\n const buildEntryPoint = type !== ApplicationBundleType.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 if (!generateEmptyShell) {\n if (autoViewsAndRoutes) {\n applyAutomaticViewsAndRoutes(appShellConfiguration, root, viewsFolder);\n }\n\n if (devMode && autoDevMenu) {\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((acc, dep) => {\n acc[`/bundles/${dep.bundle}`] = dep.virtualSrc;\n return acc;\n }, {} as Record<string, string>)\n }),\n\n // generate the importmap for shared dependencies and for apps referenced in the config file\n generateImportmap(\n {\n ...SHARED_DEPENDENCIES.reduce((acc, dep) => {\n acc[dep.moduleId] = `./bundles/${dep.bundle}`;\n return acc;\n }, {} as Record<string, string>),\n\n \"@hv/uikit-icons/\": \"./icons/\",\n\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 ...SHARED_DEPENDENCIES.map(dep => dep.moduleId),\n \"@self\",\n packageJson.name\n ],\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 ),\n\n // serve the app shell config file as json and watch for changes\n serveAppShellConfig(\n appShellConfiguration,\n root,\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": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "AppShell Vite Plugin",
|
|
5
5
|
"author": "Hitachi Vantara - Boba Fett Team",
|
|
6
6
|
"type": "module",
|
|
@@ -34,7 +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.9.
|
|
37
|
+
"@hitachivantara/app-shell-shared": "0.9.1",
|
|
38
|
+
"@hitachivantara/uikit-react-icons": "^5.6.0",
|
|
38
39
|
"@hitachivantara/uikit-react-shared": "^5.1.0",
|
|
39
40
|
"@rollup/plugin-commonjs": "^24.0.0",
|
|
40
41
|
"@rollup/plugin-json": "^6.0.0",
|
|
@@ -56,5 +57,5 @@
|
|
|
56
57
|
"@types/react-dom": "^18.0.11",
|
|
57
58
|
"tsc-watch": "^6.0.0"
|
|
58
59
|
},
|
|
59
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "970af0608c82bba25a19655df835aa6d4602628b"
|
|
60
61
|
}
|