@lwrjs/module-registry 0.9.0-alpha.13 → 0.9.0-alpha.14

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_diagnostics = __toModule(require("@lwrjs/diagnostics"));
30
30
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
31
+ var import_compiler = __toModule(require("@lwrjs/shared-utils/compiler"));
31
32
  var import_linker = __toModule(require("./linker/linker.cjs"));
32
33
  var import_module_record = __toModule(require("./module-record.cjs"));
33
34
  var import_amd_strategy = __toModule(require("./linker/strategies/amd-strategy.cjs"));
@@ -109,23 +110,16 @@ var LwrModuleRegistry = class {
109
110
  const {runtimeEnvironment} = this.context;
110
111
  const {minify, sourceMapUrl} = runtimeEnvironment;
111
112
  const sourcemap = typeof sourceMapUrl === "string" || !minify;
112
- const {code: lockerizedCode} = this.context.compiler.lockerize(moduleCompiled, locker, sourcemap);
113
+ const {code: lockerizedCode} = (0, import_compiler.lockerize)(moduleCompiled, locker, sourcemap);
113
114
  moduleCompiled.compiledSource = lockerizedCode;
114
115
  }
115
- const moduleRecord = await (0, import_module_record.getModuleRecord)(moduleCompiled, this, this.context.compiler);
116
+ const moduleRecord = await (0, import_module_record.getModuleRecord)(moduleCompiled, this);
116
117
  return {...moduleCompiled, moduleRecord};
117
118
  }
118
119
  async getLinkedModule(moduleId, runtimeEnvironment, runtimeParams) {
119
120
  const moduleEntry = await this.getModuleEntry(moduleId, runtimeParams);
120
121
  const id = moduleEntry.id;
121
- const {
122
- format,
123
- compat,
124
- debug,
125
- minify,
126
- bundle,
127
- env: {NODE_ENV: envMode}
128
- } = runtimeEnvironment;
122
+ const {format, compat, debug, minify, bundle} = runtimeEnvironment;
129
123
  const locale = runtimeParams?.["locale"];
130
124
  const environment = runtimeParams?.["environment"];
131
125
  const {
@@ -152,17 +146,10 @@ var LwrModuleRegistry = class {
152
146
  const moduleDef = await this.getModule(moduleId, runtimeParams);
153
147
  const moduleLinked = await this.createLinkedModuleDefinition(moduleDef, runtimeEnvironment, runtimeParams);
154
148
  if (format === "amd" && !bundle) {
155
- moduleLinked.linkedSource = (await this.context.compiler.convertToAmd(moduleLinked.linkedSource, {
149
+ moduleLinked.linkedSource = (await (0, import_compiler.convertToAmd)(moduleLinked.linkedSource, {
156
150
  id: moduleLinked.id
157
151
  })).code;
158
152
  }
159
- const minified = !!minify && !debug;
160
- if (minified && !bundle) {
161
- moduleLinked.linkedSource = (await this.context.compiler.minifyJavascript(moduleLinked.linkedSource)).code;
162
- moduleLinked.linkedConfig.minified = true;
163
- } else {
164
- moduleLinked.linkedSource = (await this.context.compiler.parseJavascript(moduleLinked.linkedSource, {envMode})).code;
165
- }
166
153
  if (cacheDisabled === false) {
167
154
  const linkedMap = this.moduleLinkedCache.get(id) || new Map();
168
155
  linkedMap.set((0, import_shared_utils.getCacheKeyFromJson)({
@@ -69,12 +69,12 @@ async function resolveExternalImport(registry, moduleSpecifier, importeeEntry, l
69
69
  interchangeable: dependencyModuleEntry.interchangeable
70
70
  };
71
71
  }
72
- async function getModuleRecord(compiledModule, registry, compiler) {
72
+ async function getModuleRecord(compiledModule, registry) {
73
73
  const imports = [];
74
74
  const dynamicImports = [];
75
75
  const {compiledMetadata: defaultCompilerMetadata, moduleEntry, version} = compiledModule;
76
76
  const compiledMetadata = defaultCompilerMetadata || {};
77
- const {imports: compiledModuleImports, dynamicImports: compiledModuleDynamicImports} = await compiler.getModuleMetadata(compiledModule.compiledSource);
77
+ const {imports: compiledModuleImports, dynamicImports: compiledModuleDynamicImports} = await (0, import_shared_utils.getImportMetadata)(compiledModule.compiledSource);
78
78
  Object.assign(compiledMetadata, {
79
79
  imports: compiledModuleImports,
80
80
  dynamicImports: compiledModuleDynamicImports
@@ -1,8 +1,7 @@
1
- import { ModuleProvider, LinkedModuleDefinition, LwrAppObserver, Compiler, RuntimeEnvironment, LwrAppEmitter, ModuleRegistry, ModuleEntry, PublicModuleRegistry, NormalizedLwrGlobalConfig, ModuleDefinition, AbstractModuleId, ModuleId, RuntimeParams } from '@lwrjs/types';
1
+ import type { AbstractModuleId, LinkedModuleDefinition, LwrAppEmitter, LwrAppObserver, ModuleDefinition, ModuleEntry, ModuleId, ModuleProvider, ModuleRegistry, NormalizedLwrGlobalConfig, PublicModuleRegistry, RuntimeEnvironment, RuntimeParams } from '@lwrjs/types';
2
2
  interface RegistryContext {
3
3
  appObserver: LwrAppObserver;
4
4
  appEmitter: LwrAppEmitter;
5
- compiler: Compiler;
6
5
  runtimeEnvironment: RuntimeEnvironment;
7
6
  }
8
7
  export declare class LwrModuleRegistry implements ModuleRegistry {
package/build/es/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  import { LwrUnresolvableError, createSingleDiagnosticError, descriptions } from '@lwrjs/diagnostics';
2
2
  import { discoverInterchangeableModules, getCacheKeyFromJson, InflightTasks, LATEST_SIGNATURE, ModuleNameType, } from '@lwrjs/shared-utils';
3
+ // dependencies @locker/compiler and rollup are in this package.json is to satisfy the shared-utils/compiler optional dependencies
4
+ import { convertToAmd, lockerize } from '@lwrjs/shared-utils/compiler';
3
5
  import { link } from './linker/linker.js';
4
6
  import { getModuleRecord } from './module-record.js';
5
7
  import amdLinkingStrategy from './linker/strategies/amd-strategy.js';
@@ -98,17 +100,17 @@ export class LwrModuleRegistry {
98
100
  // in addition to being explicitly enabled.
99
101
  const { minify, sourceMapUrl } = runtimeEnvironment;
100
102
  const sourcemap = typeof sourceMapUrl === 'string' || !minify;
101
- const { code: lockerizedCode } = this.context.compiler.lockerize(moduleCompiled, locker, sourcemap);
103
+ const { code: lockerizedCode } = lockerize(moduleCompiled, locker, sourcemap);
102
104
  moduleCompiled.compiledSource = lockerizedCode;
103
105
  }
104
- const moduleRecord = await getModuleRecord(moduleCompiled, this, this.context.compiler);
106
+ const moduleRecord = await getModuleRecord(moduleCompiled, this);
105
107
  return { ...moduleCompiled, moduleRecord };
106
108
  }
107
109
  async getLinkedModule(moduleId, runtimeEnvironment, runtimeParams) {
108
110
  const moduleEntry = await this.getModuleEntry(moduleId, runtimeParams);
109
111
  const id = moduleEntry.id;
110
112
  // cache key pivots from the runtimeEnvironment
111
- const { format, compat, debug, minify, bundle, env: { NODE_ENV: envMode }, } = runtimeEnvironment;
113
+ const { format, compat, debug, minify, bundle } = runtimeEnvironment;
112
114
  const locale = runtimeParams?.['locale'];
113
115
  const environment = runtimeParams?.['environment'];
114
116
  const { locker: { enabled: lockerEnabled }, } = this.globalConfig;
@@ -135,19 +137,10 @@ export class LwrModuleRegistry {
135
137
  // the bundler will convert the linked source to AMD when bundling is enabled
136
138
  if (format === 'amd' && !bundle) {
137
139
  // convert the linkedSource to the transport AMD format
138
- moduleLinked.linkedSource = (await this.context.compiler.convertToAmd(moduleLinked.linkedSource, {
140
+ moduleLinked.linkedSource = (await convertToAmd(moduleLinked.linkedSource, {
139
141
  id: moduleLinked.id,
140
142
  })).code;
141
143
  }
142
- const minified = !!minify && !debug;
143
- // the bundler will minify when bundling is enabled
144
- if (minified && !bundle) {
145
- moduleLinked.linkedSource = (await this.context.compiler.minifyJavascript(moduleLinked.linkedSource)).code;
146
- moduleLinked.linkedConfig.minified = true;
147
- }
148
- else {
149
- moduleLinked.linkedSource = (await this.context.compiler.parseJavascript(moduleLinked.linkedSource, { envMode })).code;
150
- }
151
144
  // Add to cache
152
145
  if (cacheDisabled === false) {
153
146
  const linkedMap = this.moduleLinkedCache.get(id) || new Map();
@@ -1,3 +1,3 @@
1
- import { ModuleCompiled, ModuleRecord, ModuleRegistry, Compiler } from '@lwrjs/types';
2
- export declare function getModuleRecord(compiledModule: ModuleCompiled, registry: ModuleRegistry, compiler: Compiler): Promise<ModuleRecord>;
1
+ import type { ModuleCompiled, ModuleRecord, ModuleRegistry } from '@lwrjs/types';
2
+ export declare function getModuleRecord(compiledModule: ModuleCompiled, registry: ModuleRegistry): Promise<ModuleRecord>;
3
3
  //# sourceMappingURL=module-record.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import path from 'path';
2
- import { explodeSpecifier, ModuleNameType } from '@lwrjs/shared-utils';
2
+ import { explodeSpecifier, getImportMetadata, ModuleNameType } from '@lwrjs/shared-utils';
3
3
  async function resolveRelativeImport(registry, moduleSpecifier, importeeEntry, version, location) {
4
4
  // Resolve any relative parts in the import specifier
5
5
  // eg: "c/app#app.html" => "c/app"
@@ -51,13 +51,13 @@ async function resolveExternalImport(registry, moduleSpecifier, importeeEntry, l
51
51
  interchangeable: dependencyModuleEntry.interchangeable,
52
52
  };
53
53
  }
54
- export async function getModuleRecord(compiledModule, registry, compiler) {
54
+ export async function getModuleRecord(compiledModule, registry) {
55
55
  const imports = [];
56
56
  const dynamicImports = [];
57
57
  const { compiledMetadata: defaultCompilerMetadata, moduleEntry, version } = compiledModule;
58
58
  const compiledMetadata = defaultCompilerMetadata || {};
59
59
  // Get imports metadata and merge with rest of compiledModule metadata
60
- const { imports: compiledModuleImports, dynamicImports: compiledModuleDynamicImports } = await compiler.getModuleMetadata(compiledModule.compiledSource);
60
+ const { imports: compiledModuleImports, dynamicImports: compiledModuleDynamicImports } = await getImportMetadata(compiledModule.compiledSource);
61
61
  Object.assign(compiledMetadata, {
62
62
  imports: compiledModuleImports,
63
63
  dynamicImports: compiledModuleDynamicImports,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.9.0-alpha.13",
7
+ "version": "0.9.0-alpha.14",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -30,16 +30,18 @@
30
30
  "build/**/*.d.ts"
31
31
  ],
32
32
  "dependencies": {
33
- "@lwrjs/diagnostics": "0.9.0-alpha.13",
34
- "@lwrjs/shared-utils": "0.9.0-alpha.13",
35
- "es-module-lexer": "^0.3.18"
33
+ "@locker/compiler": "0.18.2",
34
+ "@lwrjs/diagnostics": "0.9.0-alpha.14",
35
+ "@lwrjs/shared-utils": "0.9.0-alpha.14",
36
+ "es-module-lexer": "^0.3.18",
37
+ "rollup": "~2.45.2"
36
38
  },
37
39
  "devDependencies": {
38
- "@lwrjs/types": "0.9.0-alpha.13",
40
+ "@lwrjs/types": "0.9.0-alpha.14",
39
41
  "@types/es-module-lexer": "^0.3.0"
40
42
  },
41
43
  "engines": {
42
44
  "node": ">=14.15.4 <19"
43
45
  },
44
- "gitHead": "fa30915a685f6e8c5c2895d0c053d59145780123"
46
+ "gitHead": "64e0ba617151429da6e09f1a9686628f64183d25"
45
47
  }