@lwrjs/module-bundler 0.13.0-alpha.9 → 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.
@@ -28,6 +28,7 @@ __export(exports, {
28
28
  });
29
29
  var import_amd_common = __toModule(require("./utils/amd-common.cjs"));
30
30
  var import_esbuild_utils = __toModule(require("./utils/esbuild-utils.cjs"));
31
+ var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
31
32
  var AmdBundlerProvider = class {
32
33
  constructor(options, {config, moduleRegistry}) {
33
34
  this.name = "amd-bundle-provider";
@@ -49,6 +50,7 @@ var AmdBundlerProvider = class {
49
50
  } else {
50
51
  bundle.code = await (0, import_esbuild_utils.parseJavascript)(bundle.code, {envMode});
51
52
  }
53
+ bundle.integrity = (0, import_shared_utils.createIntegrityHash)(bundle.code);
52
54
  return bundle;
53
55
  }
54
56
  }
@@ -27,6 +27,7 @@ __export(exports, {
27
27
  default: () => amd_runtime_bundle_provider_default
28
28
  });
29
29
  var import_amd_common = __toModule(require("./utils/amd-common.cjs"));
30
+ var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
30
31
  var AmdBundlerProvider = class {
31
32
  constructor(options, {config, moduleRegistry}) {
32
33
  this.name = "amd-runtime-bundle-provider";
@@ -38,7 +39,11 @@ var AmdBundlerProvider = class {
38
39
  const {moduleRegistry, config} = this;
39
40
  const {minify, debug} = runtimeEnvironment;
40
41
  const minified = minify && !debug;
41
- return await (0, import_amd_common.amdBundler)(moduleId, moduleRegistry, minified, runtimeEnvironment, runtimeParams, config, bundleConfigOverrides);
42
+ const bundle = await (0, import_amd_common.amdBundler)(moduleId, moduleRegistry, minified, runtimeEnvironment, runtimeParams, config, bundleConfigOverrides);
43
+ if (bundle) {
44
+ bundle.integrity = (0, import_shared_utils.createIntegrityHash)(bundle.code);
45
+ }
46
+ return bundle;
42
47
  }
43
48
  }
44
49
  };
@@ -105,6 +105,7 @@ async function esmBundler(moduleId, moduleRegistry, runtimeEnvironment, runtimeP
105
105
  code,
106
106
  config: {external, exclude},
107
107
  map: bundleMap,
108
+ integrity: (0, import_shared_utils.createIntegrityHash)(code),
108
109
  bundleRecord: {
109
110
  imports: Array.from(requiredImports.values()),
110
111
  dynamicImports: Array.from(dynamicImports.values()),
@@ -29,10 +29,6 @@ __export(exports, {
29
29
  });
30
30
  var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
31
31
  var import_esbuild = __toModule(require("esbuild"));
32
- var import_features = __toModule(require("@lwc/features"));
33
- var lwcFeatureFlags = "default" in import_features.default ? import_features.default.default : import_features.default;
34
- var lwcFeatureFlagDefinitions = Object.fromEntries(Object.keys(lwcFeatureFlags).map((feature) => [`lwcRuntimeFlags.${feature}`, "false"]));
35
- delete lwcFeatureFlagDefinitions["lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE"];
36
32
  var esbuild = import_esbuild.default;
37
33
  if (!import_esbuild.default) {
38
34
  try {
@@ -46,8 +42,7 @@ async function minifyJavascript(source) {
46
42
  loader: "js",
47
43
  minify: true,
48
44
  define: {
49
- "process.env.NODE_ENV": JSON.stringify("production"),
50
- ...lwcFeatureFlagDefinitions
45
+ "process.env.NODE_ENV": JSON.stringify("production")
51
46
  }
52
47
  });
53
48
  return code;
@@ -64,8 +59,7 @@ async function parseJavascript(source, options) {
64
59
  loader: "js",
65
60
  minify: false,
66
61
  define: {
67
- "process.env.NODE_ENV": JSON.stringify(options.envMode),
68
- ...lwcFeatureFlagDefinitions
62
+ "process.env.NODE_ENV": JSON.stringify(options.envMode)
69
63
  }
70
64
  });
71
65
  return code;
@@ -1,5 +1,6 @@
1
1
  import { amdBundler } from './utils/amd-common.js';
2
2
  import { minifyJavascript, parseJavascript } from './utils/esbuild-utils.js';
3
+ import { createIntegrityHash } from '@lwrjs/shared-utils';
3
4
  export default class AmdBundlerProvider {
4
5
  constructor(options, { config, moduleRegistry }) {
5
6
  this.name = 'amd-bundle-provider';
@@ -20,6 +21,7 @@ export default class AmdBundlerProvider {
20
21
  else {
21
22
  bundle.code = await parseJavascript(bundle.code, { envMode });
22
23
  }
24
+ bundle.integrity = createIntegrityHash(bundle.code);
23
25
  return bundle;
24
26
  }
25
27
  }
@@ -1,4 +1,5 @@
1
1
  import { amdBundler } from './utils/amd-common.js';
2
+ import { createIntegrityHash } from '@lwrjs/shared-utils';
2
3
  export default class AmdBundlerProvider {
3
4
  constructor(options, { config, moduleRegistry }) {
4
5
  this.name = 'amd-runtime-bundle-provider';
@@ -10,8 +11,12 @@ export default class AmdBundlerProvider {
10
11
  const { moduleRegistry, config } = this;
11
12
  const { minify, debug } = runtimeEnvironment;
12
13
  const minified = minify && !debug;
13
- return await amdBundler(moduleId, moduleRegistry, minified, // will minify using rollup/terser if true - MRT runtime friendly
14
+ const bundle = await amdBundler(moduleId, moduleRegistry, minified, // will minify using rollup/terser if true - MRT runtime friendly
14
15
  runtimeEnvironment, runtimeParams, config, bundleConfigOverrides);
16
+ if (bundle) {
17
+ bundle.integrity = createIntegrityHash(bundle.code);
18
+ }
19
+ return bundle;
15
20
  }
16
21
  }
17
22
  }
@@ -3,7 +3,7 @@ import { BundleSpan, getTracer } from '@lwrjs/instrumentation';
3
3
  import { bundleDefinitions } from './utils/rollup-esm-bundler-plugin.js';
4
4
  import { minifyJavascript } from './utils/esbuild-utils.js';
5
5
  import { overrideBundleConfig } from './utils/bundle-common.js';
6
- import { PROTOCOL_HTTP, PROTOCOL_HTTPS } from '@lwrjs/shared-utils';
6
+ import { PROTOCOL_HTTP, PROTOCOL_HTTPS, createIntegrityHash } from '@lwrjs/shared-utils';
7
7
  export default class EsmBundlerProvider {
8
8
  constructor(_options, { config, moduleRegistry }) {
9
9
  this.name = 'esm-bundle-provider';
@@ -79,6 +79,7 @@ async function esmBundler(moduleId, moduleRegistry, runtimeEnvironment, runtimeP
79
79
  code,
80
80
  config: { external, exclude },
81
81
  map: bundleMap,
82
+ integrity: createIntegrityHash(code),
82
83
  bundleRecord: {
83
84
  imports: Array.from(requiredImports.values()),
84
85
  dynamicImports: Array.from(dynamicImports.values()),
@@ -1,12 +1,5 @@
1
1
  import { logger } from '@lwrjs/diagnostics';
2
2
  import esbuildEsm from 'esbuild';
3
- import features from '@lwc/features';
4
- // In certain envs, this default import is not compiled correctly
5
- const lwcFeatureFlags = 'default' in features ? features.default : features;
6
- // Set every LWC feature flag to false, so that the unused code can be tree-shaken
7
- const lwcFeatureFlagDefinitions = Object.fromEntries(Object.keys(lwcFeatureFlags).map((feature) => [`lwcRuntimeFlags.${feature}`, 'false']));
8
- // We cannot set mixed mode to false across the app; it varies by route.
9
- delete lwcFeatureFlagDefinitions['lwcRuntimeFlags.ENABLE_MIXED_SHADOW_MODE'];
10
3
  // https://github.com/evanw/esbuild/issues/706
11
4
  // Fixed in 0.11.0 but upgrading past 0.9.7 has caused breaking changes for consumers...
12
5
  // https://github.com/salesforce-experience-platform-emu/lwr/issues/1014
@@ -31,7 +24,6 @@ export async function minifyJavascript(source) {
31
24
  // Remove assertions by tree shaking the computed expression
32
25
  define: {
33
26
  'process.env.NODE_ENV': JSON.stringify('production'),
34
- ...lwcFeatureFlagDefinitions,
35
27
  },
36
28
  });
37
29
  return code;
@@ -55,7 +47,6 @@ export async function parseJavascript(source, options) {
55
47
  // Remove assertions by tree shaking the computed expression
56
48
  define: {
57
49
  'process.env.NODE_ENV': JSON.stringify(options.envMode),
58
- ...lwcFeatureFlagDefinitions,
59
50
  },
60
51
  });
61
52
  return code;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.13.0-alpha.9",
7
+ "version": "0.13.0",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -38,7 +38,7 @@
38
38
  },
39
39
  "scripts": {
40
40
  "build": "tsc -b",
41
- "clean": "rm -rf build",
41
+ "clean": "rimraf build",
42
42
  "test": "jest"
43
43
  },
44
44
  "files": [
@@ -47,28 +47,25 @@
47
47
  "build/**/*.d.ts"
48
48
  ],
49
49
  "dependencies": {
50
- "@lwrjs/diagnostics": "0.13.0-alpha.9",
51
- "@lwrjs/instrumentation": "0.13.0-alpha.9",
52
- "@lwrjs/shared-utils": "0.13.0-alpha.9",
53
- "@rollup/plugin-replace": "^5.0.5",
50
+ "@lwrjs/diagnostics": "0.13.0",
51
+ "@lwrjs/instrumentation": "0.13.0",
52
+ "@lwrjs/shared-utils": "0.13.0",
53
+ "@rollup/plugin-replace": "^5.0.7",
54
54
  "rollup": "^2.78.0"
55
55
  },
56
56
  "devDependencies": {
57
- "@lwrjs/types": "0.13.0-alpha.9",
57
+ "@lwrjs/types": "0.13.0",
58
58
  "jest": "^26.6.3",
59
59
  "ts-jest": "^26.5.6"
60
60
  },
61
61
  "optionalDependencies": {
62
62
  "esbuild": "^0.9.7"
63
63
  },
64
- "peerDependencies": {
65
- "@lwc/features": ">= 2.x"
66
- },
67
64
  "engines": {
68
65
  "node": ">=18.0.0"
69
66
  },
70
67
  "volta": {
71
68
  "extends": "../../../package.json"
72
69
  },
73
- "gitHead": "a2a9e1dbf39a7b04c7a43433e004895b6f4c51a3"
70
+ "gitHead": "21dc6b8ffd2e633f36b46daf9e1563992c5143b9"
74
71
  }