@equinor/fusion-framework-vite-plugin-spa 1.0.0-next.5 → 1.0.0-next.6

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.
@@ -15,5 +15,5 @@
15
15
  * @constant
16
16
  * @type {string}
17
17
  */
18
- export declare const html = "\n <!DOCTYPE html>\n <html>\n <head>\n <title>%FUSION_SPA_TITLE%</title>\n <meta name=\"mode\" content=\"%MODE%\">\n <meta name=\"fusion-spa-plugin-version\" content=\"1.0.0-next.5\">\n <link rel=\"stylesheet\" href=\"https://cdn.eds.equinor.com/font/equinor-font.css\" />\n <script type=\"module\" src=\"%FUSION_SPA_BOOTSTRAP%\"></script>\n <script>\n // suppress console error for custom elements already defined. \n // WebComponents should be added by the portal, but not removed from application\n const _customElementsDefine = window.customElements.define;\n window.customElements.define = (name, cl, conf) => {\n if (!customElements.get(name)) {\n _customElementsDefine.call(window.customElements, name, cl, conf);\n }\n };\n </script>\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n font-family: 'EquinorFont', sans-serif;\n }\n </style>\n </head>\n <body></body>\n </html>\n";
18
+ export declare const html = "\n <!DOCTYPE html>\n <html>\n <head>\n <title>%FUSION_SPA_TITLE%</title>\n <meta name=\"mode\" content=\"%MODE%\">\n <meta name=\"fusion-spa-plugin-version\" content=\"1.0.0-next.6\">\n <link rel=\"stylesheet\" href=\"https://cdn.eds.equinor.com/font/equinor-font.css\" />\n <script type=\"module\" src=\"%FUSION_SPA_BOOTSTRAP%\"></script>\n <script>\n // suppress console error for custom elements already defined. \n // WebComponents should be added by the portal, but not removed from application\n const _customElementsDefine = window.customElements.define;\n window.customElements.define = (name, cl, conf) => {\n if (!customElements.get(name)) {\n _customElementsDefine.call(window.customElements, name, cl, conf);\n }\n };\n </script>\n <style>\n html, body {\n margin: 0;\n padding: 0;\n height: 100%;\n font-family: 'EquinorFont', sans-serif;\n }\n </style>\n </head>\n <body></body>\n </html>\n";
19
19
  export default html;
@@ -1 +1 @@
1
- export declare const version = "1.0.0-next.5";
1
+ export declare const version = "1.0.0-next.6";
package/package.json CHANGED
@@ -1,13 +1,21 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-vite-plugin-spa",
3
- "version": "1.0.0-next.5",
3
+ "version": "1.0.0-next.6",
4
4
  "description": "Vite plugin for SPA development",
5
5
  "type": "module",
6
6
  "types": "dist/types/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "import": "./dist/bin/index.js",
9
+ "import": "./dist/esm/index.js",
10
10
  "types": "./dist/types/index.d.ts"
11
+ },
12
+ "./bootstrap.js": {
13
+ "import": "./dist/html/bootstrap.js",
14
+ "types": "./dist/types/bootstrap.d.ts"
15
+ },
16
+ "./sw.js": {
17
+ "import": "./dist/html/sw.js",
18
+ "types": "./dist/types/sw.d.ts"
11
19
  }
12
20
  },
13
21
  "directories": {
@@ -37,15 +45,15 @@
37
45
  "rollup": "^4.39.0",
38
46
  "typescript": "^5.5.4",
39
47
  "vite": "^6.3.5",
40
- "@equinor/fusion-framework-module-http": "^6.3.3-next.2",
41
48
  "@equinor/fusion-framework-module": "^4.4.3-next.1",
42
49
  "@equinor/fusion-framework-module-msal": "^4.0.7-next.1",
43
50
  "@equinor/fusion-framework-module-service-discovery": "^8.0.15-next.2",
44
- "@equinor/fusion-framework-vite-plugin-api-service": "^1.0.0-next.1"
51
+ "@equinor/fusion-framework-vite-plugin-api-service": "^1.0.0-next.1",
52
+ "@equinor/fusion-framework-module-http": "^6.3.3-next.2"
45
53
  },
46
54
  "scripts": {
47
- "prebuild": "tsc -b",
48
- "build": "rollup -c rollup.config.js",
55
+ "build": "tsc -b",
56
+ "postbuild": "rollup -c rollup.config.js",
49
57
  "test": "vitest"
50
58
  }
51
59
  }
package/rollup.config.js CHANGED
@@ -5,18 +5,16 @@ import commonjs from '@rollup/plugin-commonjs';
5
5
  export default [
6
6
  {
7
7
  input: {
8
- index: 'dist/esm/index.js',
9
8
  'html/bootstrap': 'dist/esm/html/bootstrap.js',
10
9
  'html/sw': 'dist/esm/html/sw.js',
11
10
  },
12
11
  output: {
13
12
  format: 'esm',
14
- dir: 'dist/bin',
13
+ dir: 'dist',
15
14
  entryFileNames: '[name].js',
16
15
  sourcemap: true,
17
16
  strict: false,
18
17
  },
19
- external: ['fsevents', 'jiti', 'lightningcss', 'yaml'],
20
18
  plugins: [resolve({ preferBuiltins: true }), commonjs()],
21
19
  },
22
20
  ];
package/src/plugin.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import type { Plugin } from 'vite';
2
2
 
3
+ import { fileURLToPath } from 'node:url';
4
+
3
5
  import mergeWith from 'lodash.mergewith';
4
6
 
5
7
  import defaultTemplate from './html/index.html.js';
@@ -44,16 +46,22 @@ export const plugin = <TEnv extends TemplateEnv = TemplateEnv>(
44
46
 
45
47
  return {
46
48
  name: 'fusion-framework-plugin-spa',
47
- resolveId(id) {
49
+ resolveId: async (id) => {
48
50
  // resolve resource aliases to the correct path
49
51
  switch (id) {
50
- case '/@fusion-spa-bootstrap.js':
51
- return new URL('./html/bootstrap.js', import.meta.url).pathname;
52
- case '/@fusion-spa-sw.js':
53
- return new URL('./html/sw.js', import.meta.url).pathname;
52
+ case '/@fusion-spa-bootstrap.js': {
53
+ const file = await import.meta.resolve(
54
+ '@equinor/fusion-framework-vite-plugin-spa/bootstrap.js',
55
+ );
56
+ return fileURLToPath(file);
57
+ }
58
+ case '/@fusion-spa-sw.js': {
59
+ const file = await import.meta.resolve('@equinor/fusion-framework-vite-plugin-spa/sw.js');
60
+ return fileURLToPath(file);
61
+ }
54
62
  }
55
63
  },
56
- config(config, configEnv) {
64
+ config: async (config, configEnv) => {
57
65
  const templateEnvPrefix = options?.templateEnvPrefix ?? 'FUSION_SPA_';
58
66
  // generate environment variables from plugin options
59
67
  const pluginEnvObj = { ...defaultEnv, ...options?.generateTemplateEnv?.(configEnv) };
@@ -79,8 +87,8 @@ export const plugin = <TEnv extends TemplateEnv = TemplateEnv>(
79
87
  config.server ??= {};
80
88
  config.server.fs ??= {};
81
89
  config.server.fs.allow ??= [];
82
- // allow access to the template file
83
- config.server.fs.allow.push(new URL('./html', import.meta.url).pathname);
90
+ // allow access to the html directory
91
+ config.server.fs.allow.push(new URL('../html', import.meta.url).pathname);
84
92
 
85
93
  log?.info(`plugin configured for ${env.FUSION_SPA_PORTAL_ID}`);
86
94
  },
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '1.0.0-next.5';
2
+ export const version = '1.0.0-next.6';
@@ -1,8 +0,0 @@
1
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
-
3
- function getDefaultExportFromCjs (x) {
4
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
- }
6
-
7
- export { commonjsGlobal as c, getDefaultExportFromCjs as g };
8
- //# sourceMappingURL=_commonjsHelpers-BFTU3MAI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"_commonjsHelpers-BFTU3MAI.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}