@lwc/sfdc-lwc-compiler 13.3.25 → 13.3.27
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/dist/__tests__/compile-state-manager-instrumentation.spec.d.ts +1 -0
- package/dist/__tests__/compile-state-manager-instrumentation.spec.js +654 -0
- package/dist/__tests__/compile-state-manager-instrumentation.spec.js.map +1 -0
- package/dist/__tests__/compile.spec.js +1 -1
- package/dist/__tests__/compile.spec.js.map +1 -1
- package/dist/compile.d.ts +2 -1
- package/dist/compile.js +1 -1
- package/dist/compile.js.map +1 -1
- package/dist/compiler/__tests__/dynamic-imports.spec.js +1 -1
- package/dist/compiler/__tests__/dynamic-imports.spec.js.map +1 -1
- package/dist/compiler/__tests__/output.spec.js +1 -1
- package/dist/compiler/__tests__/output.spec.js.map +1 -1
- package/dist/compiler/compile.js +13 -2
- package/dist/compiler/compile.js.map +1 -1
- package/dist/compiler/plugins/__tests__/utils.spec.d.ts +1 -0
- package/dist/compiler/plugins/__tests__/utils.spec.js +127 -0
- package/dist/compiler/plugins/__tests__/utils.spec.js.map +1 -0
- package/dist/compiler/plugins/apexLoggingRollupPlugin.d.ts +3 -3
- package/dist/compiler/plugins/apexLoggingRollupPlugin.js +6 -57
- package/dist/compiler/plugins/apexLoggingRollupPlugin.js.map +1 -1
- package/dist/compiler/plugins/luvioRollupPlugin.d.ts +3 -3
- package/dist/compiler/plugins/luvioRollupPlugin.js +6 -57
- package/dist/compiler/plugins/luvioRollupPlugin.js.map +1 -1
- package/dist/compiler/plugins/plugins.d.ts +2 -1
- package/dist/compiler/plugins/plugins.js +4 -1
- package/dist/compiler/plugins/plugins.js.map +1 -1
- package/dist/compiler/plugins/stateManagerInstrumentationPlugin.d.ts +72 -0
- package/dist/compiler/plugins/stateManagerInstrumentationPlugin.js +170 -0
- package/dist/compiler/plugins/stateManagerInstrumentationPlugin.js.map +1 -0
- package/dist/compiler/plugins/utils.d.ts +12 -0
- package/dist/compiler/plugins/utils.js +62 -0
- package/dist/compiler/plugins/utils.js.map +1 -0
- package/package.json +21 -21
|
@@ -32,17 +32,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.apexLoggingTransformPlugin = apexLoggingTransformPlugin;
|
|
40
37
|
exports.transformSync = transformSync;
|
|
41
|
-
exports.default = default_1;
|
|
42
|
-
const path_1 = __importDefault(require("path"));
|
|
43
|
-
const core_1 = require("@babel/core");
|
|
44
38
|
const t = __importStar(require("@babel/types"));
|
|
45
|
-
const
|
|
39
|
+
const utils_1 = require("./utils");
|
|
46
40
|
/**
|
|
47
41
|
This plugin injects the tagName into imperative apex call expressions sourceContext parameter:
|
|
48
42
|
|
|
@@ -154,55 +148,10 @@ function apexLoggingTransformPlugin() {
|
|
|
154
148
|
* @returns An object with the transformed code.
|
|
155
149
|
*/
|
|
156
150
|
function transformSync(src, id, { sourcemap, name, namespace }) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
babelrc: false,
|
|
162
|
-
configFile: false,
|
|
163
|
-
// extend any custom plugins
|
|
164
|
-
// decorators are still considered an experimental feature by default
|
|
165
|
-
// we use this syntax plugin to make sure babel parses but not transforms the decorators
|
|
166
|
-
// transform will be handled by the lwc transform plugin
|
|
167
|
-
plugins: [
|
|
168
|
-
[
|
|
169
|
-
apexLoggingTransformPlugin,
|
|
170
|
-
{
|
|
171
|
-
name,
|
|
172
|
-
namespace,
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
],
|
|
176
|
-
};
|
|
177
|
-
let result;
|
|
178
|
-
try {
|
|
179
|
-
result = (0, core_1.transformSync)(src, transformOptions);
|
|
180
|
-
if (result === null) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
code: result.code === null ? undefined : result.code,
|
|
185
|
-
map: result.map,
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
catch (e) {
|
|
189
|
-
throw (0, errors_1.normalizeToCompilerError)(errors_1.TransformerErrors.JS_TRANSFORMER_ERROR, e, { filename: id });
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
function isScriptFile(filename) {
|
|
193
|
-
const extName = path_1.default.extname(filename);
|
|
194
|
-
return extName === '.js' || extName === '.ts';
|
|
195
|
-
}
|
|
196
|
-
function default_1(options) {
|
|
197
|
-
return {
|
|
198
|
-
name: 'luvio-apex-logging-transform-plugin',
|
|
199
|
-
transform(code, id) {
|
|
200
|
-
// only transform 'Js' script files
|
|
201
|
-
if (!isScriptFile(id)) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
return transformSync(code, id, options);
|
|
205
|
-
},
|
|
206
|
-
};
|
|
151
|
+
return (0, utils_1.runBabelTransformSync)(src, id, sourcemap, apexLoggingTransformPlugin, {
|
|
152
|
+
name,
|
|
153
|
+
namespace,
|
|
154
|
+
});
|
|
207
155
|
}
|
|
156
|
+
exports.default = (0, utils_1.createRollupTransformPlugin)('luvio-apex-logging-transform-plugin', transformSync);
|
|
208
157
|
//# sourceMappingURL=apexLoggingRollupPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apexLoggingRollupPlugin.js","sourceRoot":"","sources":["../../../src/compiler/plugins/apexLoggingRollupPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apexLoggingRollupPlugin.js","sourceRoot":"","sources":["../../../src/compiler/plugins/apexLoggingRollupPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,gEA+FC;AASD,sCASC;AAlKD,gDAAkC;AAClC,mCAA6E;AAwB7E;;;;;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,EAAE,cAAc,CAAC;yBAC5D,CAAC,CACL;qBACJ,CAAC,CAAC;oBAEH,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;wBAC3B,8BAA8B;wBAC9B,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;4BACrC,SAAS;wBACb,CAAC;wBACD,uGAAuG;wBACvG,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;4BACvC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC;wBAC5D,CAAC;wBAED,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;oBAC5C,CAAC;gBACL,CAAC;aACJ;SACJ;KACJ,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CACzB,GAAW,EACX,EAAU,EACV,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAoB;IAEhD,OAAO,IAAA,6BAAqB,EAAC,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,0BAA0B,EAAE;QACzE,IAAI;QACJ,SAAS;KACZ,CAAC,CAAC;AACP,CAAC;AAED,kBAAe,IAAA,mCAA2B,EACtC,qCAAqC,EACrC,aAAa,CAChB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as t from '@babel/types';
|
|
2
2
|
import type { NodePath, PluginObj, PluginPass } from '@babel/core';
|
|
3
|
-
import type {
|
|
3
|
+
import type { TransformResult } from 'rollup';
|
|
4
4
|
type GQLReplacement = {
|
|
5
5
|
hash: string;
|
|
6
6
|
taggedTemplateExpressionPath: NodePath<t.TaggedTemplateExpression>;
|
|
@@ -30,5 +30,5 @@ export declare function luvioGQLTransformPlugin(): PluginObj<LuvioPluginPass>;
|
|
|
30
30
|
* @returns An object with the transformed code.
|
|
31
31
|
*/
|
|
32
32
|
export declare function transformSync(src: string, id: string, { sourcemap, name, namespace }: TransformOptions): TransformResult;
|
|
33
|
-
|
|
34
|
-
export
|
|
33
|
+
declare const _default: (options: TransformOptions) => import("rollup").Plugin;
|
|
34
|
+
export default _default;
|
|
@@ -32,18 +32,12 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
36
|
exports.luvioGQLTransformPlugin = luvioGQLTransformPlugin;
|
|
40
37
|
exports.transformSync = transformSync;
|
|
41
|
-
exports.default = default_1;
|
|
42
38
|
const node_crypto_1 = require("node:crypto");
|
|
43
|
-
const path_1 = __importDefault(require("path"));
|
|
44
|
-
const core_1 = require("@babel/core");
|
|
45
39
|
const t = __importStar(require("@babel/types"));
|
|
46
|
-
const
|
|
40
|
+
const utils_1 = require("./utils");
|
|
47
41
|
const GQL_MODULE_SPECIFIER = 'lightning/uiGraphQLApi';
|
|
48
42
|
const GQL_IMPORT_IDENTIFIER = 'gql';
|
|
49
43
|
function isValidGQLTagImport(path) {
|
|
@@ -161,55 +155,10 @@ function luvioGQLTransformPlugin() {
|
|
|
161
155
|
* @returns An object with the transformed code.
|
|
162
156
|
*/
|
|
163
157
|
function transformSync(src, id, { sourcemap, name, namespace }) {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
babelrc: false,
|
|
169
|
-
configFile: false,
|
|
170
|
-
// extend any custom plugins
|
|
171
|
-
// decorators are still considered an experimental feature by default
|
|
172
|
-
// we use this syntax plugin to make sure babel parses but not transforms the decorators
|
|
173
|
-
// transform will be handled by the lwc transform plugin
|
|
174
|
-
plugins: [
|
|
175
|
-
[
|
|
176
|
-
luvioGQLTransformPlugin,
|
|
177
|
-
{
|
|
178
|
-
name,
|
|
179
|
-
namespace,
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
],
|
|
183
|
-
};
|
|
184
|
-
let result;
|
|
185
|
-
try {
|
|
186
|
-
result = (0, core_1.transformSync)(src, transformOptions);
|
|
187
|
-
if (result === null) {
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
return {
|
|
191
|
-
code: result.code === null ? undefined : result.code,
|
|
192
|
-
map: result.map,
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
catch (e) {
|
|
196
|
-
throw (0, errors_1.normalizeToCompilerError)(errors_1.TransformerErrors.JS_TRANSFORMER_ERROR, e, { filename: id });
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function isScriptFile(filename) {
|
|
200
|
-
const extName = path_1.default.extname(filename);
|
|
201
|
-
return extName === '.js' || extName === '.ts';
|
|
202
|
-
}
|
|
203
|
-
function default_1(options) {
|
|
204
|
-
return {
|
|
205
|
-
name: 'luvio-rollup-plugin',
|
|
206
|
-
transform(code, id) {
|
|
207
|
-
// only transform 'Js' script files
|
|
208
|
-
if (!isScriptFile(id)) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
return transformSync(code, id, options);
|
|
212
|
-
},
|
|
213
|
-
};
|
|
158
|
+
return (0, utils_1.runBabelTransformSync)(src, id, sourcemap, luvioGQLTransformPlugin, {
|
|
159
|
+
name,
|
|
160
|
+
namespace,
|
|
161
|
+
});
|
|
214
162
|
}
|
|
163
|
+
exports.default = (0, utils_1.createRollupTransformPlugin)('luvio-rollup-plugin', transformSync);
|
|
215
164
|
//# sourceMappingURL=luvioRollupPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"luvioRollupPlugin.js","sourceRoot":"","sources":["../../../src/compiler/plugins/luvioRollupPlugin.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"luvioRollupPl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luginTransform: (options: object, compilationCache?: Map<string, any>) => import("rollup").Plugin;
|
|
8
8
|
declare const rollupPluginLuvio: (options: object, compilationCache?: Map<string, any>) => import("rollup").Plugin;
|
|
9
9
|
declare const rollupPluginApexLogging: (options: object, compilationCache?: Map<string, any>) => import("rollup").Plugin;
|
|
10
|
-
|
|
10
|
+
declare const rollupPluginStateManagerInstrumentation: (options: object, compilationCache?: Map<string, any>) => import("rollup").Plugin;
|
|
11
|
+
export { rollupPluginReplace, rollupPluginResolve, rollupPluginTransform, rollupPluginMinify, rollupPluginCSSResolver, rollupPluginImportMetaEnv, rollupPluginHmrLex, rollupPluginLuvio, rollupPluginApexLogging, rollupPluginStateManagerInstrumentation, };
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.rollupPluginApexLogging = exports.rollupPluginLuvio = exports.rollupPluginHmrLex = exports.rollupPluginImportMetaEnv = exports.rollupPluginCSSResolver = exports.rollupPluginMinify = exports.rollupPluginTransform = exports.rollupPluginResolve = exports.rollupPluginReplace = void 0;
|
|
6
|
+
exports.rollupPluginStateManagerInstrumentation = exports.rollupPluginApexLogging = exports.rollupPluginLuvio = exports.rollupPluginHmrLex = exports.rollupPluginImportMetaEnv = exports.rollupPluginCSSResolver = exports.rollupPluginMinify = exports.rollupPluginTransform = exports.rollupPluginResolve = exports.rollupPluginReplace = void 0;
|
|
7
7
|
const plugin_replace_1 = __importDefault(require("@rollup/plugin-replace"));
|
|
8
8
|
exports.rollupPluginReplace = plugin_replace_1.default;
|
|
9
9
|
const dev_server_plugin_lex_1 = __importDefault(require("@lwc/dev-server-plugin-lex"));
|
|
@@ -20,10 +20,13 @@ exports.rollupPluginImportMetaEnv = importMetaEnv_1.default;
|
|
|
20
20
|
const cssResolver_1 = __importDefault(require("./cssResolver"));
|
|
21
21
|
exports.rollupPluginCSSResolver = cssResolver_1.default;
|
|
22
22
|
const apexLoggingRollupPlugin_1 = __importDefault(require("./apexLoggingRollupPlugin"));
|
|
23
|
+
const stateManagerInstrumentationPlugin_1 = __importDefault(require("./stateManagerInstrumentationPlugin"));
|
|
23
24
|
const rollupPluginTransform = (0, cacheableRollupPlugin_1.default)(transform_1.default);
|
|
24
25
|
exports.rollupPluginTransform = rollupPluginTransform;
|
|
25
26
|
const rollupPluginLuvio = (0, cacheableRollupPlugin_1.default)(luvioRollupPlugin_1.default);
|
|
26
27
|
exports.rollupPluginLuvio = rollupPluginLuvio;
|
|
27
28
|
const rollupPluginApexLogging = (0, cacheableRollupPlugin_1.default)(apexLoggingRollupPlugin_1.default);
|
|
28
29
|
exports.rollupPluginApexLogging = rollupPluginApexLogging;
|
|
30
|
+
const rollupPluginStateManagerInstrumentation = (0, cacheableRollupPlugin_1.default)(stateManagerInstrumentationPlugin_1.default);
|
|
31
|
+
exports.rollupPluginStateManagerInstrumentation = rollupPluginStateManagerInstrumentation;
|
|
29
32
|
//# sourceMappingURL=plugins.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../../src/compiler/plugins/plugins.ts"],"names":[],"mappings":";;;;;;AAAA,4EAAyD;
|
|
1
|
+
{"version":3,"file":"plugins.js","sourceRoot":"","sources":["../../../src/compiler/plugins/plugins.ts"],"names":[],"mappings":";;;;;;AAAA,4EAAyD;AAsBrD,8BAtBG,wBAAmB,CAsBH;AArBvB,uFAA4D;AA4BxD,6BA5BG,+BAAkB,CA4BH;AA1BtB,wDAA4C;AAqBxC,8BArBG,iBAAmB,CAqBH;AApBvB,4DAAuC;AACvC,sDAA0C;AAqBtC,6BArBG,gBAAkB,CAqBH;AApBtB,oFAA2D;AAC3D,4EAAiD;AACjD,oEAAwD;AAoBpD,oCApBG,uBAAyB,CAoBH;AAnB7B,gEAAoD;AAkBhD,kCAlBG,qBAAuB,CAkBH;AAjB3B,wFAA6D;AAC7D,4GAAuF;AAEvF,MAAM,qBAAqB,GAAG,IAAA,+BAAoB,EAAC,mBAAY,CAAC,CAAC;AAY7D,sDAAqB;AAXzB,MAAM,iBAAiB,GAAG,IAAA,+BAAoB,EAAC,2BAAc,CAAC,CAAC;AAiB3D,8CAAiB;AAhBrB,MAAM,uBAAuB,GAAG,IAAA,+BAAoB,EAAC,iCAAoB,CAAC,CAAC;AAiBvE,0DAAuB;AAhB3B,MAAM,uCAAuC,GAAG,IAAA,+BAAoB,EAChE,2CAAoC,CACvC,CAAC;AAeE,0FAAuC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as t from '@babel/types';
|
|
2
|
+
import type { NodePath, PluginObj, PluginPass } from '@babel/core';
|
|
3
|
+
import type { TransformResult } from 'rollup';
|
|
4
|
+
export interface TransformOptions {
|
|
5
|
+
/**
|
|
6
|
+
* If `true` a source map is generated for the transformed file.
|
|
7
|
+
*/
|
|
8
|
+
sourcemap?: boolean;
|
|
9
|
+
name: string;
|
|
10
|
+
namespace: string;
|
|
11
|
+
/**
|
|
12
|
+
* Bundle type: 'internal' means Salesforce internal module, 'platform' means external/customer module
|
|
13
|
+
*/
|
|
14
|
+
type: 'internal' | 'platform';
|
|
15
|
+
}
|
|
16
|
+
interface StateManagerPluginPass extends PluginPass {
|
|
17
|
+
opts: {
|
|
18
|
+
name: string;
|
|
19
|
+
namespace: string;
|
|
20
|
+
type: 'internal' | 'platform';
|
|
21
|
+
};
|
|
22
|
+
defineStateCallsToTransform: Array<{
|
|
23
|
+
path: NodePath<t.CallExpression>;
|
|
24
|
+
callIndex: number;
|
|
25
|
+
}>;
|
|
26
|
+
defineStateImportedIdentifiers: Map<string, t.Identifier>;
|
|
27
|
+
defineStateCallCounter: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* This plugin injects module identifier and type metadata into defineState calls at compile time.
|
|
31
|
+
*
|
|
32
|
+
* Supports defineState imports from:
|
|
33
|
+
* - '@lwc/state' (public API)
|
|
34
|
+
* - 'force/lwcStateManager' (internal Salesforce API)
|
|
35
|
+
*
|
|
36
|
+
* Example transformation (only when defineState has exactly 1 argument):
|
|
37
|
+
*
|
|
38
|
+
* import { defineState } from '@lwc/state';
|
|
39
|
+
* // OR
|
|
40
|
+
* import { defineState } from 'force/lwcStateManager';
|
|
41
|
+
*
|
|
42
|
+
* const useCounter = defineState(({ atom }) => ({ count: atom(0) }));
|
|
43
|
+
*
|
|
44
|
+
* is transformed to:
|
|
45
|
+
*
|
|
46
|
+
* const useCounter = defineState(
|
|
47
|
+
* ({ atom }) => ({ count: atom(0) }),
|
|
48
|
+
* { metadata: { definedBy: 'c/myComponent', type: 'external' } }
|
|
49
|
+
* );
|
|
50
|
+
*
|
|
51
|
+
* Multiple defineState calls in the same module get unique suffixes:
|
|
52
|
+
* - First call: c/myComponent
|
|
53
|
+
* - Second call: c/myComponent_1
|
|
54
|
+
* - Third call: c/myComponent_2
|
|
55
|
+
* etc.
|
|
56
|
+
*
|
|
57
|
+
* NOTE: Only transforms calls with exactly 1 argument to avoid interfering with existing API:
|
|
58
|
+
* - no arguments: will fail at runtime.
|
|
59
|
+
* - two arguments: the usage is already setting the metadata.
|
|
60
|
+
* - more than two arguments: the usage is already setting the metadata, extras will be ignored.
|
|
61
|
+
*/
|
|
62
|
+
export declare function stateManagerInstrumentationTransformPlugin(): PluginObj<StateManagerPluginPass>;
|
|
63
|
+
/**
|
|
64
|
+
* Transform the passed source code.
|
|
65
|
+
* @param src : raw source code
|
|
66
|
+
* @param id : filename
|
|
67
|
+
* @param options: transform options
|
|
68
|
+
* @returns An object with the transformed code.
|
|
69
|
+
*/
|
|
70
|
+
export declare function transformSync(src: string, id: string, { sourcemap, name, namespace, type }: TransformOptions): TransformResult;
|
|
71
|
+
declare const _default: (options: TransformOptions) => import("rollup").Plugin;
|
|
72
|
+
export default _default;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.stateManagerInstrumentationTransformPlugin = stateManagerInstrumentationTransformPlugin;
|
|
37
|
+
exports.transformSync = transformSync;
|
|
38
|
+
const t = __importStar(require("@babel/types"));
|
|
39
|
+
const utils_1 = require("./utils");
|
|
40
|
+
/**
|
|
41
|
+
* This plugin injects module identifier and type metadata into defineState calls at compile time.
|
|
42
|
+
*
|
|
43
|
+
* Supports defineState imports from:
|
|
44
|
+
* - '@lwc/state' (public API)
|
|
45
|
+
* - 'force/lwcStateManager' (internal Salesforce API)
|
|
46
|
+
*
|
|
47
|
+
* Example transformation (only when defineState has exactly 1 argument):
|
|
48
|
+
*
|
|
49
|
+
* import { defineState } from '@lwc/state';
|
|
50
|
+
* // OR
|
|
51
|
+
* import { defineState } from 'force/lwcStateManager';
|
|
52
|
+
*
|
|
53
|
+
* const useCounter = defineState(({ atom }) => ({ count: atom(0) }));
|
|
54
|
+
*
|
|
55
|
+
* is transformed to:
|
|
56
|
+
*
|
|
57
|
+
* const useCounter = defineState(
|
|
58
|
+
* ({ atom }) => ({ count: atom(0) }),
|
|
59
|
+
* { metadata: { definedBy: 'c/myComponent', type: 'external' } }
|
|
60
|
+
* );
|
|
61
|
+
*
|
|
62
|
+
* Multiple defineState calls in the same module get unique suffixes:
|
|
63
|
+
* - First call: c/myComponent
|
|
64
|
+
* - Second call: c/myComponent_1
|
|
65
|
+
* - Third call: c/myComponent_2
|
|
66
|
+
* etc.
|
|
67
|
+
*
|
|
68
|
+
* NOTE: Only transforms calls with exactly 1 argument to avoid interfering with existing API:
|
|
69
|
+
* - no arguments: will fail at runtime.
|
|
70
|
+
* - two arguments: the usage is already setting the metadata.
|
|
71
|
+
* - more than two arguments: the usage is already setting the metadata, extras will be ignored.
|
|
72
|
+
*/
|
|
73
|
+
function stateManagerInstrumentationTransformPlugin() {
|
|
74
|
+
return {
|
|
75
|
+
// keep options in sync with OSS LWC
|
|
76
|
+
manipulateOptions: (_opts, parserOpts) => {
|
|
77
|
+
parserOpts.plugins.push(['decorators', { decoratorsBeforeExport: true }]);
|
|
78
|
+
},
|
|
79
|
+
pre() {
|
|
80
|
+
this.defineStateCallsToTransform = [];
|
|
81
|
+
this.defineStateImportedIdentifiers = new Map();
|
|
82
|
+
this.defineStateCallCounter = 0;
|
|
83
|
+
},
|
|
84
|
+
visitor: {
|
|
85
|
+
ImportDeclaration(path, state) {
|
|
86
|
+
const sourceValue = path.node.source.value;
|
|
87
|
+
// Detect defineState imports from @lwc/state or force/lwcStateManager
|
|
88
|
+
if (sourceValue === '@lwc/state' || sourceValue === 'force/lwcStateManager') {
|
|
89
|
+
for (const specifier of path.node.specifiers) {
|
|
90
|
+
// Detect named import of defineState
|
|
91
|
+
if (t.isImportSpecifier(specifier) &&
|
|
92
|
+
t.isIdentifier(specifier.imported) &&
|
|
93
|
+
specifier.imported.name === 'defineState') {
|
|
94
|
+
state.defineStateImportedIdentifiers.set(specifier.local.name, specifier.local);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
CallExpression(path, state) {
|
|
100
|
+
const callee = path.node.callee;
|
|
101
|
+
// Identifier call: defineState()
|
|
102
|
+
if (t.isIdentifier(callee)) {
|
|
103
|
+
const localName = callee.name;
|
|
104
|
+
const identifier = state.defineStateImportedIdentifiers.get(localName);
|
|
105
|
+
if (!identifier) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
// Resolve the binding for this identifier in the current scope.
|
|
109
|
+
// If the identifier is shadowed (e.g., as a function parameter),
|
|
110
|
+
// the binding.identifier will not be the same node as the import's identifier.
|
|
111
|
+
const resolvedBinding = path.scope.getBinding(localName);
|
|
112
|
+
if (!resolvedBinding || resolvedBinding.identifier !== identifier) {
|
|
113
|
+
// The call does not reference the defineState import (likely shadowed). Skip.
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
// Only transform calls with exactly 1 argument to avoid interfering with existing API
|
|
117
|
+
if (path.node.arguments.length === 1) {
|
|
118
|
+
state.defineStateCallsToTransform.push({
|
|
119
|
+
path,
|
|
120
|
+
callIndex: state.defineStateCallCounter++,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
Program: {
|
|
126
|
+
// Process all defineState calls that we collected in the CallExpression visitor
|
|
127
|
+
exit: (_path, state) => {
|
|
128
|
+
const calls = state.defineStateCallsToTransform;
|
|
129
|
+
if (calls.length === 0) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
const { name, namespace, type } = state.opts;
|
|
133
|
+
const moduleType = type === 'internal' ? 'internal' : 'external';
|
|
134
|
+
const identifier = `${namespace}/${name}`;
|
|
135
|
+
for (const { path: callPath, callIndex } of calls) {
|
|
136
|
+
// Generate module identifier with suffix for multiple calls
|
|
137
|
+
const suffix = callIndex > 0 ? `_${callIndex}` : '';
|
|
138
|
+
const moduleIdentifier = `${identifier}${suffix}`;
|
|
139
|
+
// Create the metadata object: { metadata: { definedBy: 'c/myComponent', type: 'external' } }
|
|
140
|
+
const innerMetadataObject = t.objectExpression([
|
|
141
|
+
t.objectProperty(t.identifier('definedBy'), t.stringLiteral(moduleIdentifier)),
|
|
142
|
+
t.objectProperty(t.identifier('type'), t.stringLiteral(moduleType)),
|
|
143
|
+
]);
|
|
144
|
+
const metadataObject = t.objectExpression([
|
|
145
|
+
t.objectProperty(t.identifier('metadata'), innerMetadataObject),
|
|
146
|
+
]);
|
|
147
|
+
// Add metadata as second argument: defineState(callback, metadata)
|
|
148
|
+
callPath.node.arguments.push(metadataObject);
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Transform the passed source code.
|
|
157
|
+
* @param src : raw source code
|
|
158
|
+
* @param id : filename
|
|
159
|
+
* @param options: transform options
|
|
160
|
+
* @returns An object with the transformed code.
|
|
161
|
+
*/
|
|
162
|
+
function transformSync(src, id, { sourcemap, name, namespace, type }) {
|
|
163
|
+
return (0, utils_1.runBabelTransformSync)(src, id, sourcemap, stateManagerInstrumentationTransformPlugin, {
|
|
164
|
+
name,
|
|
165
|
+
namespace,
|
|
166
|
+
type,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
exports.default = (0, utils_1.createRollupTransformPlugin)('state-manager-instrumentation-plugin', transformSync);
|
|
170
|
+
//# sourceMappingURL=stateManagerInstrumentationPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stateManagerInstrumentationPlugin.js","sourceRoot":"","sources":["../../../src/compiler/plugins/stateManagerInstrumentationPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,gGAiGC;AASD,sCAUC;AAxLD,gDAAkC;AAClC,mCAA6E;AAkC7E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,0CAA0C;IACtD,OAAO;QACH,oCAAoC;QACpC,iBAAiB,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE;YACrC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,EAAE,sBAAsB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC9E,CAAC;QACD,GAAG;YACC,IAAI,CAAC,2BAA2B,GAAG,EAAE,CAAC;YACtC,IAAI,CAAC,8BAA8B,GAAG,IAAI,GAAG,EAAE,CAAC;YAChD,IAAI,CAAC,sBAAsB,GAAG,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,EAAE;YACL,iBAAiB,CAAC,IAAmC,EAAE,KAA6B;gBAChF,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC;gBAC3C,sEAAsE;gBACtE,IAAI,WAAW,KAAK,YAAY,IAAI,WAAW,KAAK,uBAAuB,EAAE,CAAC;oBAC1E,KAAK,MAAM,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;wBAC3C,qCAAqC;wBACrC,IACI,CAAC,CAAC,iBAAiB,CAAC,SAAS,CAAC;4BAC9B,CAAC,CAAC,YAAY,CAAC,S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;KACJ,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,aAAa,CACzB,GAAW,EACX,EAAU,EACV,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAoB;IAEtD,OAAO,IAAA,6BAAqB,EAAC,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,0CAA0C,EAAE;QACzF,IAAI;QACJ,SAAS;QACT,IAAI;KACP,CAAC,CAAC;AACP,CAAC;AAED,kBAAe,IAAA,mCAA2B,EACtC,sCAAsC,EACtC,aAAa,CAChB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PluginTarget } from '@babel/core';
|
|
2
|
+
import type { Plugin, TransformResult } from 'rollup';
|
|
3
|
+
export declare function isScriptFile(filename: string): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Runs Babel transform with shared config (no babelrc, no configFile, optional sourcemaps)
|
|
6
|
+
* and normalizes errors. Use from plugin-specific transformSync implementations.
|
|
7
|
+
*/
|
|
8
|
+
export declare function runBabelTransformSync(src: string, id: string, sourcemap: boolean | undefined, babelPlugin: PluginTarget, pluginOpts: Record<string, unknown>): TransformResult;
|
|
9
|
+
/**
|
|
10
|
+
* Creates a Rollup plugin that only transforms script files and delegates to the given transformSync.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createRollupTransformPlugin<TOptions>(pluginName: string, transformSync: (src: string, id: string, options: TOptions) => TransformResult): (options: TOptions) => Plugin;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isScriptFile = isScriptFile;
|
|
7
|
+
exports.runBabelTransformSync = runBabelTransformSync;
|
|
8
|
+
exports.createRollupTransformPlugin = createRollupTransformPlugin;
|
|
9
|
+
const path_1 = __importDefault(require("path"));
|
|
10
|
+
const core_1 = require("@babel/core");
|
|
11
|
+
const errors_1 = require("@lwc/errors");
|
|
12
|
+
function isScriptFile(filename) {
|
|
13
|
+
const extName = path_1.default.extname(filename);
|
|
14
|
+
return extName === '.js' || extName === '.ts';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Runs Babel transform with shared config (no babelrc, no configFile, optional sourcemaps)
|
|
18
|
+
* and normalizes errors. Use from plugin-specific transformSync implementations.
|
|
19
|
+
*/
|
|
20
|
+
function runBabelTransformSync(src, id, sourcemap, babelPlugin, pluginOpts) {
|
|
21
|
+
const transformOptions = {
|
|
22
|
+
filename: id,
|
|
23
|
+
sourceMaps: sourcemap,
|
|
24
|
+
// Prevent Babel from loading local configuration.
|
|
25
|
+
babelrc: false,
|
|
26
|
+
configFile: false,
|
|
27
|
+
// extend any custom plugins
|
|
28
|
+
// decorators are still considered an experimental feature by default
|
|
29
|
+
// we use this syntax plugin to make sure babel parses but not transforms the decorators
|
|
30
|
+
// transform will be handled by the lwc transform plugin
|
|
31
|
+
plugins: [[babelPlugin, pluginOpts]],
|
|
32
|
+
};
|
|
33
|
+
let result;
|
|
34
|
+
try {
|
|
35
|
+
result = (0, core_1.transformSync)(src, transformOptions);
|
|
36
|
+
if (result === null) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
code: result.code ?? undefined,
|
|
41
|
+
map: result.map,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
catch (e) {
|
|
45
|
+
throw (0, errors_1.normalizeToCompilerError)(errors_1.TransformerErrors.JS_TRANSFORMER_ERROR, e, { filename: id });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates a Rollup plugin that only transforms script files and delegates to the given transformSync.
|
|
50
|
+
*/
|
|
51
|
+
function createRollupTransformPlugin(pluginName, transformSync) {
|
|
52
|
+
return (options) => ({
|
|
53
|
+
name: pluginName,
|
|
54
|
+
transform(code, id) {
|
|
55
|
+
if (!isScriptFile(id)) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
return transformSync(code, id, options);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/compiler/plugins/utils.ts"],"names":[],"mappings":";;;;;AAMA,oCAGC;AAMD,sDAmCC;AAKD,kEAaC;AApED,gDAAwB;AACxB,sCAAkE;AAClE,wCAA0E;AAI1E,SAAgB,YAAY,CAAC,QAAgB;IACzC,MAAM,OAAO,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACvC,OAAO,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,KAAK,CAAC;AAClD,CAAC;AAED;;;GAGG;AACH,SAAgB,qBAAqB,CACjC,GAAW,EACX,EAAU,EACV,SAA8B,EAC9B,WAAyB,EACzB,UAAmC;IAEnC,MAAM,gBAAgB,GAA0B;QAC5C,QAAQ,EAAE,EAAE;QACZ,UAAU,EAAE,SAAS;QAErB,kDAAkD;QAClD,OAAO,EAAE,KAAK;QACd,UAAU,EAAE,KAAK;QAEjB,4BAA4B;QAC5B,qEAAqE;QACrE,wFAAwF;QACxF,wDAAwD;QACxD,OAAO,EAAE,CAAC,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;KACvC,CAAC;IAEF,IAAI,MAAM,CAAC;IACX,IAAI,CAAC;QACD,MAAM,GAAG,IAAA,oBAAkB,EAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;QACnD,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YAClB,OAAO;QACX,CAAC;QACD,OAAO;YACH,IAAI,EAAE,MAAM,CAAC,IAAI,IAAI,SAAS;YAC9B,GAAG,EAAE,MAAM,CAAC,GAAG;SAClB,CAAC;IACN,CAAC;IAAC,OAAO,CAAC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