@lwrjs/module-bundler 0.12.0-alpha.2 → 0.12.0-alpha.21

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.
@@ -27,11 +27,13 @@ __export(exports, {
27
27
  default: () => esm_bundle_provider_default
28
28
  });
29
29
  var import_rollup = __toModule(require("rollup"));
30
+ var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
30
31
  var import_rollup_esm_bundler_plugin = __toModule(require("./utils/rollup-esm-bundler-plugin.cjs"));
31
32
  var import_esbuild_utils = __toModule(require("./utils/esbuild-utils.cjs"));
32
33
  var import_bundle_common = __toModule(require("./utils/bundle-common.cjs"));
34
+ var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
33
35
  var EsmBundlerProvider = class {
34
- constructor(options, {config, moduleRegistry}) {
36
+ constructor(_options, {config, moduleRegistry}) {
35
37
  this.name = "esm-bundle-provider";
36
38
  this.config = config;
37
39
  this.moduleRegistry = moduleRegistry;
@@ -50,27 +52,39 @@ async function esmBundler(moduleId, moduleRegistry, runtimeEnvironment, runtimeP
50
52
  const requiredImports = new Map();
51
53
  const dynamicImports = new Map();
52
54
  const rootModuleDef = await moduleRegistry.getLinkedModule(moduleId, runtimeEnvironment, runtimeParams);
53
- const bundle = await (0, import_rollup.rollup)({
54
- input: moduleId.specifier,
55
- plugins: [
56
- (0, import_rollup_esm_bundler_plugin.bundleDefinitions)({
57
- rootModuleDef,
58
- runtimeEnvironment,
59
- moduleRegistry,
60
- exclude,
61
- alias,
62
- runtimeParams,
63
- requiredImports,
64
- dynamicImports
65
- })
66
- ],
67
- makeAbsoluteExternalsRelative: "ifRelativeSource"
68
- });
69
- const result = await bundle.generate({
70
- paths: (id2) => {
71
- return external[id2] || id2;
72
- },
73
- sourcemap: true
55
+ const result = await (0, import_instrumentation.getTracer)().trace({
56
+ name: import_instrumentation.BundleSpan.Rollup,
57
+ attributes: {
58
+ specifier: moduleId.specifier,
59
+ format: "esm"
60
+ }
61
+ }, async () => {
62
+ const bundle = await (0, import_rollup.rollup)({
63
+ input: moduleId.specifier,
64
+ plugins: [
65
+ (0, import_rollup_esm_bundler_plugin.bundleDefinitions)({
66
+ rootModuleDef,
67
+ runtimeEnvironment,
68
+ moduleRegistry,
69
+ exclude,
70
+ alias,
71
+ runtimeParams,
72
+ requiredImports,
73
+ dynamicImports
74
+ })
75
+ ],
76
+ external: Object.keys(external),
77
+ makeAbsoluteExternalsRelative: "ifRelativeSource"
78
+ });
79
+ return bundle.generate({
80
+ paths: (id2) => {
81
+ if (external[id2] && (external[id2].startsWith(import_shared_utils.PROTOCOL_HTTP) || external[id2].startsWith(import_shared_utils.PROTOCOL_HTTPS))) {
82
+ return external[id2];
83
+ }
84
+ return id2;
85
+ },
86
+ sourcemap: true
87
+ });
74
88
  });
75
89
  const bundleCode = result.output[0].code;
76
90
  const bundleMap = result.output[0].map;
@@ -26,9 +26,10 @@ __markAsModule(exports);
26
26
  __export(exports, {
27
27
  LwrModuleBundler: () => LwrModuleBundler
28
28
  });
29
+ var import_path = __toModule(require("path"));
29
30
  var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
30
31
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
31
- var import_path = __toModule(require("path"));
32
+ var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
32
33
  var TASK_POOL = new import_shared_utils.TaskPool();
33
34
  var LwrModuleBundler = class {
34
35
  constructor(config, globalConfig) {
@@ -49,6 +50,9 @@ var LwrModuleBundler = class {
49
50
  addBundleTransformers(transformers) {
50
51
  this.transformers.push(...transformers);
51
52
  }
53
+ getConfig() {
54
+ return this.bundleConfig;
55
+ }
52
56
  async getModuleBundle(moduleId, runtimeEnvironment, runtimeParams = {}, bundleConfigOverrides) {
53
57
  const {format, minify, debug} = runtimeEnvironment;
54
58
  const cacheKey = `${moduleId.specifier}|${moduleId.version}|${(0, import_shared_utils.getCacheKeyFromJson)({
@@ -65,21 +69,28 @@ var LwrModuleBundler = class {
65
69
  return bundleDef;
66
70
  }
67
71
  }
68
- return this.inflightBundleDefinitions.execute(cacheKey, () => {
69
- return TASK_POOL.execute(async () => {
70
- for (const bundler of this.providers) {
71
- const bundleDef = await bundler.bundle(moduleId, runtimeEnvironment, runtimeParams, bundleConfigOverrides);
72
- if (bundleDef) {
73
- if (!cacheDisabled) {
74
- this.cache.set(cacheKey, bundleDef);
72
+ return (0, import_instrumentation.getTracer)().trace({
73
+ name: import_instrumentation.BundleSpan.GetBundle,
74
+ attributes: {
75
+ specifier: moduleId.specifier
76
+ }
77
+ }, () => {
78
+ return this.inflightBundleDefinitions.execute(cacheKey, () => {
79
+ return TASK_POOL.execute(async () => {
80
+ for (const bundler of this.providers) {
81
+ const bundleDef = await bundler.bundle(moduleId, runtimeEnvironment, runtimeParams, bundleConfigOverrides);
82
+ if (bundleDef) {
83
+ if (!cacheDisabled) {
84
+ this.cache.set(cacheKey, bundleDef);
85
+ }
86
+ return bundleDef;
75
87
  }
76
- return bundleDef;
77
88
  }
78
- }
79
- throw (0, import_diagnostics.createSingleDiagnosticError)({
80
- description: import_diagnostics.descriptions.UNRESOLVABLE.BUNDLE(moduleId.specifier)
81
- }, import_diagnostics.LwrUnresolvableError);
82
- }, this);
89
+ throw (0, import_diagnostics.createSingleDiagnosticError)({
90
+ description: import_diagnostics.descriptions.UNRESOLVABLE.BUNDLE(moduleId.specifier)
91
+ }, import_diagnostics.LwrUnresolvableError);
92
+ }, this);
93
+ });
83
94
  });
84
95
  }
85
96
  async resolveModuleUri(moduleId, runtimeEnvironment, runtimeParams, signature) {
@@ -116,6 +127,7 @@ var LwrModuleBundler = class {
116
127
  }
117
128
  getPublicApi() {
118
129
  return {
130
+ getConfig: this.getConfig.bind(this),
119
131
  getModuleBundle: this.getModuleBundle.bind(this),
120
132
  resolveModuleUri: this.resolveModuleUri.bind(this)
121
133
  };
@@ -29,26 +29,31 @@ __export(exports, {
29
29
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
30
30
  var import_rollup = __toModule(require("rollup"));
31
31
  var import_plugin_replace = __toModule(require("@rollup/plugin-replace"));
32
+ var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
32
33
  var import_rollup_amd_bundler_plugin = __toModule(require("./rollup-amd-bundler-plugin.cjs"));
33
34
  var import_bundle_common = __toModule(require("./bundle-common.cjs"));
34
35
  var AMD_DEFINE = "LWR.define";
35
36
  var groupieCodeCache = new Map();
36
37
  function includeIdFactory(graphSpecifier, external, exclude = [], requiredImports, groups) {
37
38
  return (moduleRef) => {
39
+ const moduleIsNotRoot = graphSpecifier !== moduleRef.specifier;
38
40
  if (external[moduleRef.specifier] !== void 0) {
41
+ moduleRef.externalSrc = external[moduleRef.specifier];
42
+ if (moduleIsNotRoot) {
43
+ requiredImports.set(`${moduleRef.specifier}_${moduleRef.version || import_shared_utils.VERSION_NOT_PROVIDED}`, moduleRef);
44
+ }
39
45
  return false;
40
46
  }
41
47
  const moduleRefIsGroupie = (0, import_shared_utils.isGroupie)(moduleRef.specifier, groups);
42
48
  const rootModuleIsGroupie = (0, import_shared_utils.isGroupie)(graphSpecifier, groups);
43
- const moduleIsNotRoot = graphSpecifier !== moduleRef.specifier;
44
49
  if (moduleRefIsGroupie) {
45
50
  if (moduleIsNotRoot && !rootModuleIsGroupie) {
46
- requiredImports.set(`${moduleRef.specifier}_${moduleRef.version}`, moduleRef);
51
+ requiredImports.set(`${moduleRef.specifier}_${moduleRef.version || import_shared_utils.VERSION_NOT_PROVIDED}`, moduleRef);
47
52
  }
48
53
  return false;
49
54
  } else if (exclude?.includes(moduleRef.specifier)) {
50
55
  if (moduleIsNotRoot) {
51
- requiredImports.set(`${moduleRef.specifier}_${moduleRef.version}`, moduleRef);
56
+ requiredImports.set(`${moduleRef.specifier}_${moduleRef.version || import_shared_utils.VERSION_NOT_PROVIDED}`, moduleRef);
52
57
  }
53
58
  return false;
54
59
  }
@@ -61,11 +66,19 @@ async function bundle(id, moduleGraphs, minify = false, unVersionedAliases = fal
61
66
  "process.env.NODE_ENV": JSON.stringify("production"),
62
67
  preventAssignment: false
63
68
  }));
64
- const bundler = await (0, import_rollup.rollup)({input: id, plugins});
65
- const {output} = await bundler.generate({
66
- amd: {id, define: AMD_DEFINE},
67
- exports: "named",
68
- format: "amd"
69
+ const {output} = await (0, import_instrumentation.getTracer)().trace({
70
+ name: import_instrumentation.BundleSpan.Rollup,
71
+ attributes: {
72
+ specifier: id,
73
+ format: "amd"
74
+ }
75
+ }, async () => {
76
+ const bundler = await (0, import_rollup.rollup)({input: id, plugins});
77
+ return bundler.generate({
78
+ amd: {id, define: AMD_DEFINE},
79
+ exports: "named",
80
+ format: "amd"
81
+ });
69
82
  });
70
83
  let code = output[0].code;
71
84
  if (unVersionedAliases) {
@@ -122,6 +135,9 @@ async function getBundleCode(rootModule, moduleGraphs, includedModules, bundleGr
122
135
  } else {
123
136
  bundleGroupsIncludedModules.push(id);
124
137
  }
138
+ if ((0, import_shared_utils.isExternalSpecifier)(id, moduleRegistry.getConfig().bundleConfig)) {
139
+ return linkedDefinition.linkedSource;
140
+ }
125
141
  return bundle(id, moduleGraphs, minify, unVersionedAliases);
126
142
  }))).filter((x) => typeof x === "string");
127
143
  return bundles;
@@ -166,8 +182,8 @@ async function amdBundler(rootModuleId, moduleRegistry, minify = false, runtimeE
166
182
  for (const rawGroupieSpecifier of groupies) {
167
183
  if (rawGroupieSpecifier !== rootModuleId.specifier) {
168
184
  const groupieModuleGraph = groupModuleGraphsMap.get(rawGroupieSpecifier);
169
- const groupieSpecifer = groupieModuleGraph.graphs[0].specifier;
170
- const groupieBundles = await getBundleCode(groupieSpecifer, groupieModuleGraph, includedModules, bundleGroupsIncludedModules, dynamicImports, minify, !!runtimeEnvironment.featureFlags?.EXPERIMENTAL_UNVERSIONED_ALIASES, includeIdFactory(rawGroupieSpecifier, external, exclude, requiredImports, groups), moduleRegistry, runtimeEnvironment, runtimeParams, bundledSpecifiersMap);
185
+ const groupieSpecifier = groupieModuleGraph.graphs[0].specifier;
186
+ const groupieBundles = await getBundleCode(groupieSpecifier, groupieModuleGraph, includedModules, bundleGroupsIncludedModules, dynamicImports, minify, !!runtimeEnvironment.featureFlags?.EXPERIMENTAL_UNVERSIONED_ALIASES, includeIdFactory(rawGroupieSpecifier, external, exclude, requiredImports, groups), moduleRegistry, runtimeEnvironment, runtimeParams, bundledSpecifiersMap);
171
187
  bundles.push(...groupieBundles);
172
188
  }
173
189
  }
@@ -3,7 +3,7 @@ export default class EsmBundlerProvider implements BundleProvider {
3
3
  name: string;
4
4
  config: ProviderAppConfig;
5
5
  moduleRegistry: PublicModuleRegistry;
6
- constructor(options: {}, { config, moduleRegistry }: ProviderContext);
6
+ constructor(_options: {}, { config, moduleRegistry }: ProviderContext);
7
7
  bundle<T extends AbstractModuleId, R extends RuntimeEnvironment>(moduleId: T, runtimeEnvironment: R, runtimeParams?: RuntimeParams, bundleConfigOverrides?: BundleConfigOverrides): Promise<BundleDefinition | undefined>;
8
8
  }
9
9
  //# sourceMappingURL=esm-bundle-provider.d.ts.map
@@ -1,9 +1,11 @@
1
1
  import { rollup } from 'rollup';
2
+ import { BundleSpan, getTracer } from '@lwrjs/instrumentation';
2
3
  import { bundleDefinitions } from './utils/rollup-esm-bundler-plugin.js';
3
4
  import { minifyJavascript } from './utils/esbuild-utils.js';
4
5
  import { overrideBundleConfig } from './utils/bundle-common.js';
6
+ import { PROTOCOL_HTTP, PROTOCOL_HTTPS } from '@lwrjs/shared-utils';
5
7
  export default class EsmBundlerProvider {
6
- constructor(options, { config, moduleRegistry }) {
8
+ constructor(_options, { config, moduleRegistry }) {
7
9
  this.name = 'esm-bundle-provider';
8
10
  this.config = config;
9
11
  this.moduleRegistry = moduleRegistry;
@@ -21,29 +23,43 @@ async function esmBundler(moduleId, moduleRegistry, runtimeEnvironment, runtimeP
21
23
  const requiredImports = new Map();
22
24
  const dynamicImports = new Map();
23
25
  const rootModuleDef = await moduleRegistry.getLinkedModule(moduleId, runtimeEnvironment, runtimeParams);
24
- const bundle = await rollup({
25
- input: moduleId.specifier,
26
- plugins: [
27
- bundleDefinitions({
28
- rootModuleDef,
29
- runtimeEnvironment,
30
- moduleRegistry,
31
- exclude,
32
- alias,
33
- runtimeParams,
34
- requiredImports,
35
- dynamicImports,
36
- }),
37
- ],
38
- makeAbsoluteExternalsRelative: 'ifRelativeSource', // Fix for breaking changes in https://github.com/rollup/rollup/pull/4021
39
- });
40
- const result = await bundle.generate({
41
- paths: (id) => {
42
- // The fallback on id is important due to a rollup semantic issue:
43
- // https://github.com/rollup/rollup/issues/3831
44
- return external[id] || id;
26
+ const result = await getTracer().trace({
27
+ name: BundleSpan.Rollup,
28
+ attributes: {
29
+ specifier: moduleId.specifier,
30
+ format: 'esm',
45
31
  },
46
- sourcemap: true,
32
+ }, async () => {
33
+ const bundle = await rollup({
34
+ input: moduleId.specifier,
35
+ plugins: [
36
+ bundleDefinitions({
37
+ rootModuleDef,
38
+ runtimeEnvironment,
39
+ moduleRegistry,
40
+ exclude,
41
+ alias,
42
+ runtimeParams,
43
+ requiredImports,
44
+ dynamicImports,
45
+ }),
46
+ ],
47
+ external: Object.keys(external),
48
+ makeAbsoluteExternalsRelative: 'ifRelativeSource', // Fix for breaking changes in https://github.com/rollup/rollup/pull/4021
49
+ });
50
+ return bundle.generate({
51
+ paths: (id) => {
52
+ // The fallback on id is important due to a rollup semantic issue:
53
+ // https://github.com/rollup/rollup/issues/3831
54
+ // If external is an http:// URL use that in the ESM Module
55
+ if (external[id] &&
56
+ (external[id].startsWith(PROTOCOL_HTTP) || external[id].startsWith(PROTOCOL_HTTPS))) {
57
+ return external[id];
58
+ }
59
+ return id;
60
+ },
61
+ sourcemap: true,
62
+ });
47
63
  });
48
64
  const bundleCode = result.output[0].code;
49
65
  const bundleMap = result.output[0].map;
@@ -14,6 +14,7 @@ export declare class LwrModuleBundler implements ModuleBundler {
14
14
  constructor(config: LwrModuleBundlerConfig, globalConfig: NormalizedLwrGlobalConfig);
15
15
  addBundleProviders(providers: BundleProvider[]): void;
16
16
  addBundleTransformers(transformers: UriTransformPlugin[]): void;
17
+ getConfig(): BundleConfig;
17
18
  getModuleBundle<T extends AbstractModuleId>(moduleId: T, runtimeEnvironment: SourceMapRuntimeEnvironment, runtimeParams?: RuntimeParams, bundleConfigOverrides?: BundleConfigOverrides): Promise<BundleDefinition>;
18
19
  /**
19
20
  * Resolve the URI to the bundle rooted at the `moduleId`
package/build/es/index.js CHANGED
@@ -1,6 +1,7 @@
1
+ import { join } from 'path';
1
2
  import { LwrUnresolvableError, createSingleDiagnosticError, descriptions } from '@lwrjs/diagnostics';
2
3
  import { getCacheKeyFromJson, InflightTasks, TaskPool } from '@lwrjs/shared-utils';
3
- import { join } from 'path';
4
+ import { getTracer, BundleSpan } from '@lwrjs/instrumentation';
4
5
  const TASK_POOL = new TaskPool();
5
6
  export class LwrModuleBundler {
6
7
  constructor(config, globalConfig) {
@@ -27,6 +28,9 @@ export class LwrModuleBundler {
27
28
  addBundleTransformers(transformers) {
28
29
  this.transformers.push(...transformers);
29
30
  }
31
+ getConfig() {
32
+ return this.bundleConfig;
33
+ }
30
34
  async getModuleBundle(moduleId, runtimeEnvironment, runtimeParams = {}, bundleConfigOverrides) {
31
35
  const { format, minify, debug } = runtimeEnvironment;
32
36
  const cacheKey = `${moduleId.specifier}|${moduleId.version}|${getCacheKeyFromJson({
@@ -46,25 +50,30 @@ export class LwrModuleBundler {
46
50
  return bundleDef;
47
51
  }
48
52
  }
49
- return this.inflightBundleDefinitions.execute(cacheKey, () => {
50
- // TODO add to profiling
51
- // console.log('[INFO] Create Bundle: ', cacheKey);
52
- // Run theses tasks in a task pool to throttle parallel requests.
53
- return TASK_POOL.execute(async () => {
54
- for (const bundler of this.providers) {
55
- // eslint-disable-next-line no-await-in-loop
56
- const bundleDef = await bundler.bundle(moduleId, runtimeEnvironment, runtimeParams, bundleConfigOverrides);
57
- if (bundleDef) {
58
- if (!cacheDisabled) {
59
- this.cache.set(cacheKey, bundleDef);
53
+ return getTracer().trace({
54
+ name: BundleSpan.GetBundle,
55
+ attributes: {
56
+ specifier: moduleId.specifier,
57
+ },
58
+ }, () => {
59
+ return this.inflightBundleDefinitions.execute(cacheKey, () => {
60
+ // Run theses tasks in a task pool to throttle parallel requests.
61
+ return TASK_POOL.execute(async () => {
62
+ for (const bundler of this.providers) {
63
+ // eslint-disable-next-line no-await-in-loop
64
+ const bundleDef = await bundler.bundle(moduleId, runtimeEnvironment, runtimeParams, bundleConfigOverrides);
65
+ if (bundleDef) {
66
+ if (!cacheDisabled) {
67
+ this.cache.set(cacheKey, bundleDef);
68
+ }
69
+ return bundleDef;
60
70
  }
61
- return bundleDef;
62
71
  }
63
- }
64
- throw createSingleDiagnosticError({
65
- description: descriptions.UNRESOLVABLE.BUNDLE(moduleId.specifier),
66
- }, LwrUnresolvableError);
67
- }, this);
72
+ throw createSingleDiagnosticError({
73
+ description: descriptions.UNRESOLVABLE.BUNDLE(moduleId.specifier),
74
+ }, LwrUnresolvableError);
75
+ }, this);
76
+ });
68
77
  });
69
78
  }
70
79
  /**
@@ -115,6 +124,7 @@ export class LwrModuleBundler {
115
124
  }
116
125
  getPublicApi() {
117
126
  return {
127
+ getConfig: this.getConfig.bind(this),
118
128
  getModuleBundle: this.getModuleBundle.bind(this),
119
129
  resolveModuleUri: this.resolveModuleUri.bind(this),
120
130
  };
@@ -1,27 +1,34 @@
1
- import { GraphDepth, createAmdAlias, explodeSpecifier, getModuleGraphs, getSpecifier, getGroupName, isGroupie, getCacheKeyFromJson, } from '@lwrjs/shared-utils';
1
+ import { GraphDepth, createAmdAlias, explodeSpecifier, getModuleGraphs, getSpecifier, getGroupName, isGroupie, getCacheKeyFromJson, VERSION_NOT_PROVIDED, isExternalSpecifier, } from '@lwrjs/shared-utils';
2
2
  import { rollup } from 'rollup';
3
3
  import replace from '@rollup/plugin-replace';
4
+ import { BundleSpan, getTracer } from '@lwrjs/instrumentation';
4
5
  import { bundleDefinitions } from './rollup-amd-bundler-plugin.js';
5
6
  import { overrideBundleConfig } from './bundle-common.js';
6
7
  const AMD_DEFINE = 'LWR.define';
7
8
  const groupieCodeCache = new Map();
8
9
  function includeIdFactory(graphSpecifier, external, exclude = [], requiredImports, groups) {
9
10
  return (moduleRef) => {
11
+ const moduleIsNotRoot = graphSpecifier !== moduleRef.specifier;
10
12
  // Do not bundle externals, including the loader module, which is auto bundled
11
13
  // with the shim + loader combo
12
14
  if (external[moduleRef.specifier] !== undefined) {
13
- // Do not include externals in the required imports but also return false to indicate it should not be in the bundle
15
+ // Include externals just mark them as such
16
+ moduleRef.externalSrc = external[moduleRef.specifier];
17
+ if (moduleIsNotRoot) {
18
+ // Include externals in the required imports
19
+ requiredImports.set(`${moduleRef.specifier}_${moduleRef.version || VERSION_NOT_PROVIDED}`, moduleRef);
20
+ }
21
+ // return false to indicate it should not be in the bundle
14
22
  return false;
15
23
  }
16
24
  const moduleRefIsGroupie = isGroupie(moduleRef.specifier, groups);
17
25
  const rootModuleIsGroupie = isGroupie(graphSpecifier, groups);
18
- const moduleIsNotRoot = graphSpecifier !== moduleRef.specifier;
19
26
  if (moduleRefIsGroupie) {
20
27
  // If this is part of bundle group return false to indicate it should not be in the bundle
21
28
  // but add it to the requiredImports so it shows up as a static dependency of the bundle.
22
29
  // However, skip this if the requested specifier is also part of the same group.
23
30
  if (moduleIsNotRoot && !rootModuleIsGroupie) {
24
- requiredImports.set(`${moduleRef.specifier}_${moduleRef.version}`, moduleRef);
31
+ requiredImports.set(`${moduleRef.specifier}_${moduleRef.version || VERSION_NOT_PROVIDED}`, moduleRef);
25
32
  }
26
33
  return false;
27
34
  }
@@ -29,7 +36,7 @@ function includeIdFactory(graphSpecifier, external, exclude = [], requiredImport
29
36
  // If this is a bundle exclude return false to indicate it should not be in the bundle
30
37
  // but add it to the requiredImports so it shows up as a static dependency of the bundle.
31
38
  if (moduleIsNotRoot) {
32
- requiredImports.set(`${moduleRef.specifier}_${moduleRef.version}`, moduleRef);
39
+ requiredImports.set(`${moduleRef.specifier}_${moduleRef.version || VERSION_NOT_PROVIDED}`, moduleRef);
33
40
  }
34
41
  return false;
35
42
  }
@@ -45,11 +52,19 @@ async function bundle(id, moduleGraphs, minify = false, unVersionedAliases = fal
45
52
  'process.env.NODE_ENV': JSON.stringify('production'),
46
53
  preventAssignment: false,
47
54
  }));
48
- const bundler = await rollup({ input: id, plugins });
49
- const { output } = await bundler.generate({
50
- amd: { id, define: AMD_DEFINE },
51
- exports: 'named',
52
- format: 'amd',
55
+ const { output } = await getTracer().trace({
56
+ name: BundleSpan.Rollup,
57
+ attributes: {
58
+ specifier: id,
59
+ format: 'amd',
60
+ },
61
+ }, async () => {
62
+ const bundler = await rollup({ input: id, plugins });
63
+ return bundler.generate({
64
+ amd: { id, define: AMD_DEFINE },
65
+ exports: 'named',
66
+ format: 'amd',
67
+ });
53
68
  });
54
69
  let code = output[0].code;
55
70
  if (unVersionedAliases) {
@@ -119,6 +134,10 @@ async function getBundleCode(rootModule, moduleGraphs, includedModules, bundleGr
119
134
  // we need to still keep track of roots for bundle groups
120
135
  bundleGroupsIncludedModules.push(id);
121
136
  }
137
+ // If this is a external dependency just return the linked source no need to bundle.
138
+ if (isExternalSpecifier(id, moduleRegistry.getConfig().bundleConfig)) {
139
+ return linkedDefinition.linkedSource;
140
+ }
122
141
  // bundle all dependencies for the linked definition and convert to AMD
123
142
  return bundle(id, moduleGraphs, minify, unVersionedAliases);
124
143
  }))).filter((x) => typeof x === 'string');
@@ -171,9 +190,9 @@ export async function amdBundler(rootModuleId, moduleRegistry, minify = false, r
171
190
  for (const rawGroupieSpecifier of groupies) {
172
191
  if (rawGroupieSpecifier !== rootModuleId.specifier) {
173
192
  const groupieModuleGraph = groupModuleGraphsMap.get(rawGroupieSpecifier);
174
- const groupieSpecifer = groupieModuleGraph.graphs[0].specifier;
193
+ const groupieSpecifier = groupieModuleGraph.graphs[0].specifier;
175
194
  // eslint-disable-next-line no-await-in-loop
176
- const groupieBundles = await getBundleCode(groupieSpecifer, groupieModuleGraph, includedModules, bundleGroupsIncludedModules, dynamicImports, minify, !!runtimeEnvironment.featureFlags?.EXPERIMENTAL_UNVERSIONED_ALIASES, includeIdFactory(rawGroupieSpecifier, external, exclude, requiredImports, groups), moduleRegistry, runtimeEnvironment, runtimeParams, bundledSpecifiersMap);
195
+ const groupieBundles = await getBundleCode(groupieSpecifier, groupieModuleGraph, includedModules, bundleGroupsIncludedModules, dynamicImports, minify, !!runtimeEnvironment.featureFlags?.EXPERIMENTAL_UNVERSIONED_ALIASES, includeIdFactory(rawGroupieSpecifier, external, exclude, requiredImports, groups), moduleRegistry, runtimeEnvironment, runtimeParams, bundledSpecifiersMap);
177
196
  bundles.push(...groupieBundles);
178
197
  }
179
198
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.12.0-alpha.2",
7
+ "version": "0.12.0-alpha.21",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -47,13 +47,14 @@
47
47
  "build/**/*.d.ts"
48
48
  ],
49
49
  "dependencies": {
50
- "@lwrjs/diagnostics": "0.12.0-alpha.2",
51
- "@lwrjs/shared-utils": "0.12.0-alpha.2",
50
+ "@lwrjs/diagnostics": "0.12.0-alpha.21",
51
+ "@lwrjs/instrumentation": "0.12.0-alpha.21",
52
+ "@lwrjs/shared-utils": "0.12.0-alpha.21",
52
53
  "@rollup/plugin-replace": "^2.4.2",
53
54
  "rollup": "^2.78.0"
54
55
  },
55
56
  "devDependencies": {
56
- "@lwrjs/types": "0.12.0-alpha.2",
57
+ "@lwrjs/types": "0.12.0-alpha.21",
57
58
  "jest": "^26.6.3",
58
59
  "ts-jest": "^26.5.6"
59
60
  },
@@ -69,5 +70,5 @@
69
70
  "volta": {
70
71
  "extends": "../../../package.json"
71
72
  },
72
- "gitHead": "586a2aa659882483af9249dc3db7fe07bc842a25"
73
+ "gitHead": "3d77678ca2f568fcbe29efa2bf7e6f75778be50c"
73
74
  }