@lwrjs/lwc-module-provider 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.
@@ -39,6 +39,9 @@ var DEFAULT_BABEL_CONFIG = {
39
39
  }
40
40
  };
41
41
  var LwcCompiler = class {
42
+ constructor(compiler) {
43
+ this.compiler = compiler;
44
+ }
42
45
  async compileFile(source, config) {
43
46
  const {enableLightningWebSecurityTransforms, filename, name, namespace, scopedStyles} = config;
44
47
  if (source.startsWith(import_utils.EXPLICIT_CONSTANT)) {
@@ -106,9 +109,14 @@ var LwcCompiler = class {
106
109
  import_diagnostics.logger.debug({
107
110
  label: "LwcCompiler",
108
111
  message: "transformSync",
109
- additionalInfo: {filename, transformConfig}
112
+ additionalInfo: {
113
+ filename,
114
+ transformConfig,
115
+ version: this.compiler ? this.compiler.version : import_compiler.version
116
+ }
110
117
  });
111
- const compilerResult = (0, import_compiler.transformSync)(source, filename, transformConfig);
118
+ const transformer = this.compiler ? this.compiler.transformSync : import_compiler.transformSync;
119
+ const compilerResult = transformer(source, filename, transformConfig);
112
120
  import_diagnostics.logger.verbose({
113
121
  label: "LwcCompiler",
114
122
  message: "transformSync result",
@@ -48,7 +48,6 @@ var LwcModuleProvider = class {
48
48
  this.watchedModuleContextMap = new Map();
49
49
  this.moduleEntryVersionCache = new Map();
50
50
  this.importerMappingCache = new Map();
51
- this.lwcCompiler = new import_compiler.LwcCompiler();
52
51
  this.inflightGetModuleJobs = new import_shared_utils.InflightTasks();
53
52
  this.inflightGetModuleEntryJobs = new import_shared_utils.InflightTasks();
54
53
  const {disableCaching} = options;
@@ -58,6 +57,7 @@ var LwcModuleProvider = class {
58
57
  this.watcher = watchFiles && watcherFactory ? (0, import_utils.setUpWatcher)(watcherFactory, this.onModuleChange.bind(this)) : void 0;
59
58
  this.moduleFsCacheEnabled = disableCaching !== void 0 ? !disableCaching : true;
60
59
  this.interchangeableModulesEnabled = !!environment?.default;
60
+ this.lwcCompiler = new import_compiler.LwcCompiler(options.lwcCompiler);
61
61
  if (this.moduleFsCacheEnabled) {
62
62
  const {lwcCacheDir, lwcCacheIndex} = (0, import_cache.setupModuleCache)(cacheDir);
63
63
  this.lwcCacheDir = lwcCacheDir;
@@ -1,8 +1,15 @@
1
1
  import type { CompilerResult, LwcCompilerConfig } from '@lwrjs/types';
2
+ import { transformSync } from '@lwc/compiler';
2
3
  export interface BundleFiles {
3
4
  [filename: string]: string;
4
5
  }
6
+ export interface CompilerFromLWC {
7
+ transformSync: typeof transformSync;
8
+ version: string;
9
+ }
5
10
  export declare class LwcCompiler {
11
+ private compiler;
12
+ constructor(compiler?: CompilerFromLWC);
6
13
  compileFile(source: string, config: LwcCompilerConfig): Promise<CompilerResult>;
7
14
  }
8
15
  //# sourceMappingURL=compiler.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import { transformSync as babelTransform } from '@babel/core';
2
- import { transformSync } from '@lwc/compiler';
2
+ import { transformSync, version as lwcCompilerVersion } from '@lwc/compiler';
3
3
  import { EXPLICIT_CONSTANT } from './utils.js';
4
4
  import { logger } from '@lwrjs/diagnostics';
5
5
  const DEFAULT_BABEL_CONFIG = {
@@ -11,6 +11,10 @@ const DEFAULT_BABEL_CONFIG = {
11
11
  },
12
12
  };
13
13
  export class LwcCompiler {
14
+ constructor(compiler) {
15
+ // Allow callers to pass in their own version of the LWC compiler
16
+ this.compiler = compiler;
17
+ }
14
18
  // compileFile takes a html, css, typescript, etc, and transforms it to a es6 module
15
19
  async compileFile(source, config) {
16
20
  const { enableLightningWebSecurityTransforms, filename, name, namespace, scopedStyles } = config;
@@ -81,9 +85,14 @@ export class LwcCompiler {
81
85
  logger.debug({
82
86
  label: 'LwcCompiler',
83
87
  message: 'transformSync',
84
- additionalInfo: { filename, transformConfig },
88
+ additionalInfo: {
89
+ filename,
90
+ transformConfig,
91
+ version: this.compiler ? this.compiler.version : lwcCompilerVersion,
92
+ },
85
93
  });
86
- const compilerResult = transformSync(source, filename, transformConfig);
94
+ const transformer = this.compiler ? this.compiler.transformSync : transformSync;
95
+ const compilerResult = transformer(source, filename, transformConfig);
87
96
  logger.verbose({
88
97
  label: 'LwcCompiler',
89
98
  message: 'transformSync result',
@@ -1,6 +1,8 @@
1
1
  import type { ModuleCompiled, ModuleEntry, ModuleProvider, ModuleSource, ProviderContext, AbstractModuleId } from '@lwrjs/types';
2
+ import type { CompilerFromLWC } from './compiler.js';
2
3
  export interface LwcModuleProviderOptions {
3
4
  disableCaching?: boolean;
5
+ lwcCompiler?: CompilerFromLWC;
4
6
  }
5
7
  export default class LwcModuleProvider implements ModuleProvider {
6
8
  name: string;
package/build/es/index.js CHANGED
@@ -15,7 +15,6 @@ export default class LwcModuleProvider {
15
15
  this.watchedModuleContextMap = new Map();
16
16
  this.moduleEntryVersionCache = new Map();
17
17
  this.importerMappingCache = new Map();
18
- this.lwcCompiler = new LwcCompiler();
19
18
  this.inflightGetModuleJobs = new InflightTasks();
20
19
  this.inflightGetModuleEntryJobs = new InflightTasks();
21
20
  const { disableCaching } = options;
@@ -28,6 +27,7 @@ export default class LwcModuleProvider {
28
27
  : undefined;
29
28
  this.moduleFsCacheEnabled = disableCaching !== undefined ? !disableCaching : true;
30
29
  this.interchangeableModulesEnabled = !!environment?.default;
30
+ this.lwcCompiler = new LwcCompiler(options.lwcCompiler);
31
31
  // Module Cache setup
32
32
  if (this.moduleFsCacheEnabled) {
33
33
  const { lwcCacheDir, lwcCacheIndex } = setupModuleCache(cacheDir);
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",
@@ -29,15 +29,18 @@
29
29
  "build/**/*.cjs",
30
30
  "build/**/*.d.ts"
31
31
  ],
32
+ "scripts": {
33
+ "build": "tsc -b"
34
+ },
32
35
  "dependencies": {
33
- "@babel/preset-typescript": "^7.24.1",
34
- "@lwrjs/diagnostics": "0.13.0-alpha.9",
35
- "@lwrjs/fs-watch": "0.13.0-alpha.9",
36
- "@lwrjs/shared-utils": "0.13.0-alpha.9",
36
+ "@babel/preset-typescript": "^7.24.7",
37
+ "@lwrjs/diagnostics": "0.13.0",
38
+ "@lwrjs/fs-watch": "0.13.0",
39
+ "@lwrjs/shared-utils": "0.13.0",
37
40
  "fs-extra": "^11.2.0"
38
41
  },
39
42
  "devDependencies": {
40
- "@lwrjs/types": "0.13.0-alpha.9",
43
+ "@lwrjs/types": "0.13.0",
41
44
  "typescript": "^4.9.5"
42
45
  },
43
46
  "peerDependencies": {
@@ -47,5 +50,5 @@
47
50
  "engines": {
48
51
  "node": ">=18.0.0"
49
52
  },
50
- "gitHead": "a2a9e1dbf39a7b04c7a43433e004895b6f4c51a3"
53
+ "gitHead": "21dc6b8ffd2e633f36b46daf9e1563992c5143b9"
51
54
  }