@soleil-se/build-app 1.11.1 → 1.11.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleil-se/build-app",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "bin": {
5
5
  "build-app": "./bin/index.js",
6
6
  "sv-app-build": "./bin/index.js"
package/rollup/client.js CHANGED
@@ -16,8 +16,9 @@ import getPostcssPlugin from './api/getPostcssPlugin.js';
16
16
  import getTerserPlugin from './api/getTerserPlugin.js';
17
17
  import getStringPlugin from './api/getStringPlugin.js';
18
18
 
19
- import sitevision from './plugins/sitevisionClient.js';
20
- import bundleSize from './plugins/bundleSize.js';
19
+ import sitevisionPlugin from './plugins/sitevisionClient.js';
20
+ import bundleSizePlugin from './plugins/bundleSize.js';
21
+ import amdGlobalsPlugin from './plugins/amdGlobals.js';
21
22
 
22
23
  export default function rollupClient({
23
24
  debug,
@@ -35,14 +36,14 @@ export default function rollupClient({
35
36
  let bundleCache;
36
37
  let plugins;
37
38
 
38
- const external = Object.keys(globals);
39
- if (bundled) external.push(...getSitevisionClientPackages());
39
+ const external = bundled ? getSitevisionClientPackages() : Object.keys(globals);
40
40
 
41
41
  return async () => {
42
42
  if (!fse.existsSync(input)) return Promise.resolve();
43
43
 
44
44
  plugins = plugins || [
45
- bundled ? sitevision() : false,
45
+ bundled ? sitevisionPlugin() : false,
46
+ bundled ? amdGlobalsPlugin({ globals }) : false,
46
47
  getReplaceClientPlugin(),
47
48
  getAliasClientPlugin(),
48
49
  getNodeResolvePlugin({ input }),
@@ -52,7 +53,7 @@ export default function rollupClient({
52
53
  getBabelClientPlugin(),
53
54
  json(),
54
55
  getStringPlugin(),
55
- showSize && bundleSize(),
56
+ showSize && bundleSizePlugin(),
56
57
  getTerserPlugin({ debug }),
57
58
  ];
58
59
 
@@ -0,0 +1,32 @@
1
+ export default function amdGlobals({ globals } = {}) {
2
+ const ignored = [];
3
+
4
+ function shouldLoad(id) {
5
+ return !ignored.includes(id);
6
+ }
7
+
8
+ return {
9
+ name: 'rollup-plugin-amd-globals',
10
+ resolveId(importee) {
11
+ if (!Object.keys(globals).includes(importee)) {
12
+ // Should be handled as usual.
13
+ return null;
14
+ }
15
+ // Most likely a global dependency.
16
+ // Do not ask other plugins or check the file system to find it.
17
+ if (!ignored.includes(importee)) {
18
+ ignored.push(importee);
19
+ }
20
+ return importee;
21
+ },
22
+ load(id) {
23
+ if (shouldLoad(id)) {
24
+ return null;
25
+ }
26
+ // The virtual source code for the provided global dependency.
27
+ return {
28
+ code: `export default window['${globals[id]}'];`,
29
+ };
30
+ },
31
+ };
32
+ }