@wyw-in-js/transform 0.1.1 → 0.2.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.
- package/esm/index.js +4 -1
- package/esm/index.js.map +1 -1
- package/esm/options/loadBabelOptions.js +1 -1
- package/esm/options/loadBabelOptions.js.map +1 -1
- package/esm/plugins/babel-transform.js +2 -2
- package/esm/plugins/babel-transform.js.map +1 -1
- package/esm/plugins/collector.js +4 -4
- package/esm/plugins/collector.js.map +1 -1
- package/esm/plugins/preeval.js +11 -11
- package/esm/plugins/preeval.js.map +1 -1
- package/esm/plugins/shaker.js +5 -5
- package/esm/plugins/shaker.js.map +1 -1
- package/esm/shaker.js +2 -2
- package/esm/shaker.js.map +1 -1
- package/esm/transform/Entrypoint.helpers.js +1 -2
- package/esm/transform/Entrypoint.helpers.js.map +1 -1
- package/esm/transform/Entrypoint.js +4 -4
- package/esm/transform/Entrypoint.js.map +1 -1
- package/esm/transform/generators/collect.js +3 -2
- package/esm/transform/generators/collect.js.map +1 -1
- package/esm/transform/generators/evalFile.js +6 -6
- package/esm/transform/generators/evalFile.js.map +1 -1
- package/esm/transform/generators/extract.js +18 -14
- package/esm/transform/generators/extract.js.map +1 -1
- package/esm/transform/generators/transform.js +2 -2
- package/esm/transform/generators/transform.js.map +1 -1
- package/esm/transform/generators/workflow.js +3 -3
- package/esm/transform/generators/workflow.js.map +1 -1
- package/esm/transform/helpers/{loadLinariaOptions.js → loadWywOptions.js} +5 -5
- package/esm/transform/helpers/loadWywOptions.js.map +1 -0
- package/esm/transform.js +11 -10
- package/esm/transform.js.map +1 -1
- package/esm/types.js.map +1 -1
- package/esm/utils/ShakerMetadata.js +1 -1
- package/esm/utils/ShakerMetadata.js.map +1 -1
- package/esm/utils/{addIdentifierToLinariaPreval.js → addIdentifierToWywPreval.js} +10 -10
- package/esm/utils/addIdentifierToWywPreval.js.map +1 -0
- package/esm/utils/collectExportsAndImports.js +141 -53
- package/esm/utils/collectExportsAndImports.js.map +1 -1
- package/esm/utils/collectTemplateDependencies.js +2 -2
- package/esm/utils/collectTemplateDependencies.js.map +1 -1
- package/esm/utils/getTagProcessor.js +1 -1
- package/esm/utils/getTagProcessor.js.map +1 -1
- package/esm/utils/hasWywPreval.js +7 -0
- package/esm/utils/hasWywPreval.js.map +1 -0
- package/lib/index.js +28 -4
- package/lib/index.js.map +1 -1
- package/lib/options/loadBabelOptions.js +1 -1
- package/lib/options/loadBabelOptions.js.map +1 -1
- package/lib/plugins/babel-transform.js +2 -2
- package/lib/plugins/babel-transform.js.map +1 -1
- package/lib/plugins/collector.js +4 -4
- package/lib/plugins/collector.js.map +1 -1
- package/lib/plugins/preeval.js +11 -11
- package/lib/plugins/preeval.js.map +1 -1
- package/lib/plugins/shaker.js +5 -5
- package/lib/plugins/shaker.js.map +1 -1
- package/lib/shaker.js +2 -2
- package/lib/shaker.js.map +1 -1
- package/lib/transform/Entrypoint.helpers.js +1 -2
- package/lib/transform/Entrypoint.helpers.js.map +1 -1
- package/lib/transform/Entrypoint.js +4 -4
- package/lib/transform/Entrypoint.js.map +1 -1
- package/lib/transform/generators/collect.js +1 -1
- package/lib/transform/generators/collect.js.map +1 -1
- package/lib/transform/generators/evalFile.js +6 -6
- package/lib/transform/generators/evalFile.js.map +1 -1
- package/lib/transform/generators/extract.js +18 -14
- package/lib/transform/generators/extract.js.map +1 -1
- package/lib/transform/generators/transform.js +2 -2
- package/lib/transform/generators/transform.js.map +1 -1
- package/lib/transform/generators/workflow.js +3 -3
- package/lib/transform/generators/workflow.js.map +1 -1
- package/lib/transform/helpers/{loadLinariaOptions.js → loadWywOptions.js} +6 -6
- package/lib/transform/helpers/loadWywOptions.js.map +1 -0
- package/lib/transform/helpers/withDefaultServices.js +2 -2
- package/lib/transform/helpers/withDefaultServices.js.map +1 -1
- package/lib/transform.js +11 -10
- package/lib/transform.js.map +1 -1
- package/lib/types.js.map +1 -1
- package/lib/utils/ShakerMetadata.js +1 -1
- package/lib/utils/ShakerMetadata.js.map +1 -1
- package/lib/utils/{addIdentifierToLinariaPreval.js → addIdentifierToWywPreval.js} +12 -12
- package/lib/utils/addIdentifierToWywPreval.js.map +1 -0
- package/lib/utils/collectExportsAndImports.js +141 -53
- package/lib/utils/collectExportsAndImports.js.map +1 -1
- package/lib/utils/collectTemplateDependencies.js +2 -2
- package/lib/utils/collectTemplateDependencies.js.map +1 -1
- package/lib/utils/getTagProcessor.js +2 -2
- package/lib/utils/getTagProcessor.js.map +1 -1
- package/lib/utils/hasWywPreval.js +13 -0
- package/lib/utils/hasWywPreval.js.map +1 -0
- package/lib/vm/createVmContext.js +2 -2
- package/lib/vm/createVmContext.js.map +1 -1
- package/package.json +24 -21
- package/types/index.d.ts +5 -2
- package/types/index.js +9 -3
- package/types/options/loadBabelOptions.js +1 -1
- package/types/plugins/babel-transform.js +2 -2
- package/types/plugins/collector.js +4 -4
- package/types/plugins/preeval.js +11 -11
- package/types/plugins/shaker.js +5 -5
- package/types/shaker.js +2 -2
- package/types/transform/Entrypoint.d.ts +1 -1
- package/types/transform/Entrypoint.helpers.js +3 -3
- package/types/transform/Entrypoint.js +4 -4
- package/types/transform/generators/collect.js +1 -1
- package/types/transform/generators/evalFile.js +7 -7
- package/types/transform/generators/extract.js +21 -12
- package/types/transform/generators/transform.js +2 -4
- package/types/transform/generators/workflow.js +3 -3
- package/types/transform/helpers/{loadLinariaOptions.d.ts → loadWywOptions.d.ts} +1 -1
- package/types/transform/helpers/{loadLinariaOptions.js → loadWywOptions.js} +19 -19
- package/types/transform.d.ts +7 -6
- package/types/transform.js +11 -10
- package/types/types.d.ts +1 -1
- package/types/utils/ShakerMetadata.d.ts +1 -1
- package/types/utils/ShakerMetadata.js +1 -1
- package/types/utils/addIdentifierToWywPreval.d.ts +4 -0
- package/types/utils/{addIdentifierToLinariaPreval.js → addIdentifierToWywPreval.js} +12 -12
- package/types/utils/collectExportsAndImports.js +157 -58
- package/types/utils/collectTemplateDependencies.d.ts +1 -1
- package/types/utils/collectTemplateDependencies.js +2 -2
- package/types/utils/getTagProcessor.js +2 -2
- package/types/utils/hasWywPreval.d.ts +4 -0
- package/types/utils/{hasLinariaPreval.js → hasWywPreval.js} +3 -3
- package/esm/transform/helpers/loadLinariaOptions.js.map +0 -1
- package/esm/utils/addIdentifierToLinariaPreval.js.map +0 -1
- package/esm/utils/findPackageJSON.js +0 -26
- package/esm/utils/findPackageJSON.js.map +0 -1
- package/esm/utils/hasLinariaPreval.js +0 -7
- package/esm/utils/hasLinariaPreval.js.map +0 -1
- package/lib/transform/helpers/loadLinariaOptions.js.map +0 -1
- package/lib/utils/addIdentifierToLinariaPreval.js.map +0 -1
- package/lib/utils/findPackageJSON.js +0 -35
- package/lib/utils/findPackageJSON.js.map +0 -1
- package/lib/utils/hasLinariaPreval.js +0 -13
- package/lib/utils/hasLinariaPreval.js.map +0 -1
- package/types/utils/addIdentifierToLinariaPreval.d.ts +0 -4
- package/types/utils/findPackageJSON.d.ts +0 -1
- package/types/utils/findPackageJSON.js +0 -56
- package/types/utils/hasLinariaPreval.d.ts +0 -4
|
@@ -220,26 +220,55 @@ function getCalleeName(path) {
|
|
|
220
220
|
}
|
|
221
221
|
return undefined;
|
|
222
222
|
}
|
|
223
|
-
|
|
224
|
-
const name = getCalleeName(
|
|
223
|
+
const matchCall = (p, rules) => {
|
|
224
|
+
const name = getCalleeName(p);
|
|
225
225
|
if (name === undefined) {
|
|
226
|
-
return
|
|
227
|
-
}
|
|
228
|
-
|
|
226
|
+
return false;
|
|
227
|
+
}
|
|
228
|
+
return rules.some(([n, ...args]) => {
|
|
229
|
+
if (name !== n)
|
|
230
|
+
return false;
|
|
231
|
+
const fnArgs = p.get('arguments');
|
|
232
|
+
if (fnArgs.length !== args.length)
|
|
233
|
+
return false;
|
|
234
|
+
return args.every((arg, i) => {
|
|
235
|
+
if (arg === '*')
|
|
236
|
+
return true;
|
|
237
|
+
if (typeof arg === 'function')
|
|
238
|
+
return arg(fnArgs[i]);
|
|
239
|
+
return arg === fnArgs[i];
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
function getImportExportTypeByInteropFunction(path, argPath) {
|
|
244
|
+
if (matchCall(path, [['__exportStar', argPath, (p) => (0, isExports_1.isExports)(p)]])) {
|
|
229
245
|
return 're-export:*';
|
|
230
246
|
}
|
|
231
|
-
if (
|
|
232
|
-
|
|
247
|
+
if (matchCall(path, [
|
|
248
|
+
['_interopRequireDefault', argPath],
|
|
249
|
+
['_interop_require_default', argPath],
|
|
250
|
+
['__importDefault', argPath], // ?
|
|
251
|
+
])) {
|
|
233
252
|
return 'default';
|
|
234
253
|
}
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
|
|
254
|
+
if (matchCall(path, [
|
|
255
|
+
['_interopRequireWildcard', argPath],
|
|
256
|
+
['_interop_require_wildcard', argPath],
|
|
257
|
+
['__importStar', argPath],
|
|
258
|
+
['__toESM', argPath],
|
|
259
|
+
['__toModule', argPath], // esbuild <0.14.7
|
|
260
|
+
])) {
|
|
238
261
|
return 'import:*';
|
|
239
262
|
}
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
263
|
+
if (matchCall(path, [
|
|
264
|
+
['_extends', isEmptyObject, argPath],
|
|
265
|
+
['__rest', argPath, isArrayExpression],
|
|
266
|
+
['__objRest', argPath, isArrayExpression],
|
|
267
|
+
['_objectWithoutProperties', argPath, isArrayExpression],
|
|
268
|
+
['_object_without_properties', argPath, isArrayExpression],
|
|
269
|
+
['_objectDestructuringEmpty', argPath],
|
|
270
|
+
['_object_destructuring_empty', argPath], // swc >=1.3.50
|
|
271
|
+
])) {
|
|
243
272
|
return 'import:*';
|
|
244
273
|
}
|
|
245
274
|
return undefined;
|
|
@@ -252,6 +281,28 @@ function isAlreadyProcessed(path) {
|
|
|
252
281
|
}
|
|
253
282
|
return false;
|
|
254
283
|
}
|
|
284
|
+
function isRequireCall(path) {
|
|
285
|
+
return path.isCallExpression() && (0, isRequire_1.isRequire)(path.get('callee'));
|
|
286
|
+
}
|
|
287
|
+
function isEmptyObject(path) {
|
|
288
|
+
return path.isObjectExpression() && path.node.properties.length === 0;
|
|
289
|
+
}
|
|
290
|
+
function isArrayExpression(path) {
|
|
291
|
+
return path.isArrayExpression();
|
|
292
|
+
}
|
|
293
|
+
function isCallExpression(pathOrName) {
|
|
294
|
+
if (typeof pathOrName === 'string') {
|
|
295
|
+
return (p) => p.isCallExpression() &&
|
|
296
|
+
p.get('callee').isIdentifier({ name: pathOrName });
|
|
297
|
+
}
|
|
298
|
+
return pathOrName.isCallExpression();
|
|
299
|
+
}
|
|
300
|
+
function isObjectExpression(path) {
|
|
301
|
+
return path.isObjectExpression();
|
|
302
|
+
}
|
|
303
|
+
function isIdentifier(name) {
|
|
304
|
+
return (path) => path.isIdentifier({ name });
|
|
305
|
+
}
|
|
255
306
|
function collectFromRequire(path, state) {
|
|
256
307
|
if (!(0, isRequire_1.isRequire)(path))
|
|
257
308
|
return;
|
|
@@ -272,10 +323,10 @@ function collectFromRequire(path, state) {
|
|
|
272
323
|
}
|
|
273
324
|
const source = sourcePath.node.value;
|
|
274
325
|
const { parentPath: container, key } = callExpression;
|
|
275
|
-
if (container.isCallExpression()
|
|
326
|
+
if (container.isCallExpression()) {
|
|
276
327
|
// It may be transpiled import such as
|
|
277
328
|
// `var _atomic = _interopRequireDefault(require("@linaria/atomic"));`
|
|
278
|
-
const imported = getImportExportTypeByInteropFunction(container);
|
|
329
|
+
const imported = getImportExportTypeByInteropFunction(container, callExpression);
|
|
279
330
|
if (!imported) {
|
|
280
331
|
// It's not a transpiled import.
|
|
281
332
|
// TODO: Can we guess that it's a namespace import?
|
|
@@ -526,8 +577,7 @@ function collectFromExports(path, state) {
|
|
|
526
577
|
// It is `exports.foo = void 0`
|
|
527
578
|
return;
|
|
528
579
|
}
|
|
529
|
-
|
|
530
|
-
if (name === '__esModule') {
|
|
580
|
+
if (exportName === '__esModule') {
|
|
531
581
|
// eslint-disable-next-line no-param-reassign
|
|
532
582
|
state.isEsModule = true;
|
|
533
583
|
return;
|
|
@@ -600,7 +650,12 @@ function unfoldNamespaceImport(importItem) {
|
|
|
600
650
|
if (!binding?.referenced) {
|
|
601
651
|
// Imported namespace is not referenced and probably not used,
|
|
602
652
|
// but it can have side effects, so we should keep it as is
|
|
603
|
-
return [
|
|
653
|
+
return [
|
|
654
|
+
{
|
|
655
|
+
...importItem,
|
|
656
|
+
imported: 'side-effect',
|
|
657
|
+
},
|
|
658
|
+
];
|
|
604
659
|
}
|
|
605
660
|
for (const referencePath of binding?.referencePaths ?? []) {
|
|
606
661
|
if (referencePath.find((ancestor) => ancestor.isTSType() || ancestor.isFlowType())) {
|
|
@@ -640,7 +695,7 @@ function unfoldNamespaceImport(importItem) {
|
|
|
640
695
|
if (parentPath?.isCallExpression() &&
|
|
641
696
|
referencePath.listKey === 'arguments') {
|
|
642
697
|
// The defined variable is used as a function argument. Let's try to figure out what is imported.
|
|
643
|
-
const importType = getImportExportTypeByInteropFunction(parentPath);
|
|
698
|
+
const importType = getImportExportTypeByInteropFunction(parentPath, referencePath);
|
|
644
699
|
if (!importType) {
|
|
645
700
|
// Imported value is used as an unknown function argument,
|
|
646
701
|
// so we can't predict usage and import it as is.
|
|
@@ -785,9 +840,12 @@ function collectFromAssignmentExpression(path, state) {
|
|
|
785
840
|
let exported;
|
|
786
841
|
if (left.isMemberExpression() && (0, isExports_1.isExports)(left.get('object'))) {
|
|
787
842
|
const property = left.get('property');
|
|
788
|
-
if (property.isIdentifier()) {
|
|
843
|
+
if (!left.node.computed && property.isIdentifier()) {
|
|
789
844
|
exported = property.node.name;
|
|
790
845
|
}
|
|
846
|
+
else if (left.node.computed && property.isStringLiteral()) {
|
|
847
|
+
exported = property.node.value;
|
|
848
|
+
}
|
|
791
849
|
}
|
|
792
850
|
else if ((0, isExports_1.isExports)(left)) {
|
|
793
851
|
// module.exports = ...
|
|
@@ -797,9 +855,24 @@ function collectFromAssignmentExpression(path, state) {
|
|
|
797
855
|
}
|
|
798
856
|
if (!exported)
|
|
799
857
|
return;
|
|
800
|
-
if (
|
|
858
|
+
if (exported === '__esModule') {
|
|
801
859
|
// eslint-disable-next-line no-param-reassign
|
|
802
|
-
state.
|
|
860
|
+
state.isEsModule = true;
|
|
861
|
+
return;
|
|
862
|
+
}
|
|
863
|
+
if (!isRequireCall(right)) {
|
|
864
|
+
const relatedImport = state.imports.find((imp) => imp.local === right);
|
|
865
|
+
if (relatedImport) {
|
|
866
|
+
state.reexports.push({
|
|
867
|
+
exported,
|
|
868
|
+
...relatedImport,
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
else {
|
|
872
|
+
// eslint-disable-next-line no-param-reassign
|
|
873
|
+
state.exports[exported] = right;
|
|
874
|
+
}
|
|
875
|
+
path.skip();
|
|
803
876
|
return;
|
|
804
877
|
}
|
|
805
878
|
const sourcePath = right.get('arguments')?.[0];
|
|
@@ -821,10 +894,8 @@ function collectFromAssignmentExpression(path, state) {
|
|
|
821
894
|
});
|
|
822
895
|
path.skip();
|
|
823
896
|
}
|
|
824
|
-
function
|
|
825
|
-
const
|
|
826
|
-
if (!(0, isExports_1.isExports)(exports))
|
|
827
|
-
return;
|
|
897
|
+
function collectAllFromCall(path, require, state) {
|
|
898
|
+
const requireCall = typeof require === 'number' ? path.get('arguments')[require] : require;
|
|
828
899
|
if (!requireCall.isCallExpression())
|
|
829
900
|
return;
|
|
830
901
|
const callee = requireCall.get('callee');
|
|
@@ -862,25 +933,33 @@ function collectFromMap(map, state) {
|
|
|
862
933
|
addExport(returnValue, exported, state);
|
|
863
934
|
});
|
|
864
935
|
}
|
|
865
|
-
function
|
|
866
|
-
const
|
|
867
|
-
if (!sourceExports.isIdentifier({ name: 'source_exports' }))
|
|
868
|
-
return;
|
|
936
|
+
function collectMapFromCall(path, mapPosition, state) {
|
|
937
|
+
const map = path.get('arguments')[mapPosition];
|
|
869
938
|
if (!map.isObjectExpression())
|
|
870
939
|
return;
|
|
871
940
|
collectFromMap(map, state);
|
|
872
941
|
path.skip();
|
|
873
942
|
}
|
|
874
943
|
function collectFromEsbuildReExportCall(path, state) {
|
|
875
|
-
const [sourceExports,
|
|
876
|
-
if (!sourceExports.isIdentifier({ name: 'source_exports' })
|
|
944
|
+
const [sourceExports, someCall, exports] = path.get('arguments');
|
|
945
|
+
if (!sourceExports.isIdentifier({ name: 'source_exports' }) &&
|
|
946
|
+
!(0, isExports_1.isExports)(sourceExports))
|
|
877
947
|
return;
|
|
878
|
-
if (!
|
|
948
|
+
if (!someCall.isCallExpression())
|
|
879
949
|
return;
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
950
|
+
let requireCall = someCall;
|
|
951
|
+
while (!(0, isRequire_1.isRequire)(requireCall.get('callee'))) {
|
|
952
|
+
const args = requireCall.get('arguments');
|
|
953
|
+
if (args.length !== 1) {
|
|
954
|
+
return;
|
|
955
|
+
}
|
|
956
|
+
const firstArg = args[0];
|
|
957
|
+
if (!firstArg.isCallExpression()) {
|
|
958
|
+
return;
|
|
959
|
+
}
|
|
960
|
+
requireCall = firstArg;
|
|
961
|
+
}
|
|
962
|
+
if (exports !== undefined && !(0, isExports_1.isExports)(exports))
|
|
884
963
|
return;
|
|
885
964
|
const sourcePath = requireCall.get('arguments')?.[0];
|
|
886
965
|
if (!sourcePath.isStringLiteral())
|
|
@@ -893,38 +972,58 @@ function collectFromEsbuildReExportCall(path, state) {
|
|
|
893
972
|
});
|
|
894
973
|
path.skip();
|
|
895
974
|
}
|
|
896
|
-
function collectFromSwcExportCall(path, state) {
|
|
897
|
-
const [exports, map] = path.get('arguments');
|
|
898
|
-
if (!(0, isExports_1.isExports)(exports))
|
|
899
|
-
return;
|
|
900
|
-
if (!map.isObjectExpression())
|
|
901
|
-
return;
|
|
902
|
-
collectFromMap(map, state);
|
|
903
|
-
path.skip();
|
|
904
|
-
}
|
|
905
975
|
function collectFromCallExpression(path, state) {
|
|
906
976
|
const maybeExportStart = path.get('callee');
|
|
907
977
|
if (!maybeExportStart.isIdentifier()) {
|
|
908
978
|
return;
|
|
909
979
|
}
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
980
|
+
if (matchCall(path, [
|
|
981
|
+
['__exportStar', isExports_1.isExports, isCallExpression('__toModule')],
|
|
982
|
+
])) {
|
|
983
|
+
// __exportStar(exports, __toModule(require('…')));
|
|
984
|
+
const secondArg = path.get('arguments')[1];
|
|
985
|
+
collectAllFromCall(path, secondArg.get('arguments')[0], state);
|
|
986
|
+
return;
|
|
987
|
+
}
|
|
988
|
+
// TypeScript & swc
|
|
989
|
+
if (matchCall(path, [
|
|
990
|
+
['__exportStart', isRequireCall, isExports_1.isExports],
|
|
991
|
+
['_exportStar', isRequireCall, isExports_1.isExports],
|
|
992
|
+
['_export_star', isRequireCall, isExports_1.isExports],
|
|
993
|
+
['__export', isRequireCall], // TypeScript <=3.8.3
|
|
994
|
+
])) {
|
|
995
|
+
collectAllFromCall(path, 0, state);
|
|
914
996
|
return;
|
|
915
997
|
}
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
998
|
+
if (matchCall(path, [['_export', isExports_1.isExports, isObjectExpression]])) {
|
|
999
|
+
collectMapFromCall(path, 1, state);
|
|
1000
|
+
return;
|
|
919
1001
|
}
|
|
920
|
-
if (
|
|
921
|
-
|
|
1002
|
+
if (matchCall(path, [
|
|
1003
|
+
['_extends', isEmptyObject, isRequireCall], // swc <=1.3.16
|
|
1004
|
+
])) {
|
|
1005
|
+
collectAllFromCall(path, 1, state);
|
|
1006
|
+
return;
|
|
922
1007
|
}
|
|
923
1008
|
// esbuild
|
|
924
|
-
if (
|
|
925
|
-
|
|
1009
|
+
if (matchCall(path, [
|
|
1010
|
+
['__export', isExports_1.isExports, isObjectExpression],
|
|
1011
|
+
['__export', isIdentifier('source_exports'), isObjectExpression],
|
|
1012
|
+
])) {
|
|
1013
|
+
collectMapFromCall(path, 1, state);
|
|
1014
|
+
return;
|
|
926
1015
|
}
|
|
927
|
-
if (
|
|
1016
|
+
if (matchCall(path, [
|
|
1017
|
+
// Different variants of re-exports in esbuild
|
|
1018
|
+
[
|
|
1019
|
+
'__reExport',
|
|
1020
|
+
isIdentifier('source_exports'),
|
|
1021
|
+
isCallExpression,
|
|
1022
|
+
isExports_1.isExports,
|
|
1023
|
+
],
|
|
1024
|
+
['__reExport', isIdentifier('source_exports'), isCallExpression],
|
|
1025
|
+
['__reExport', isExports_1.isExports, isCallExpression],
|
|
1026
|
+
])) {
|
|
928
1027
|
collectFromEsbuildReExportCall(path, state);
|
|
929
1028
|
}
|
|
930
1029
|
}
|
|
@@ -4,7 +4,7 @@ import type { ExpressionValue } from '@wyw-in-js/shared';
|
|
|
4
4
|
import type { IImport } from './collectExportsAndImports';
|
|
5
5
|
/**
|
|
6
6
|
* Only an expression that can be evaluated in the root scope can be
|
|
7
|
-
* used in a
|
|
7
|
+
* used in a WYW template. This function tries to hoist the expression.
|
|
8
8
|
* @param ex The expression to hoist.
|
|
9
9
|
* @param evaluate If true, we try to statically evaluate the expression.
|
|
10
10
|
* @param imports All the imports of the file.
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.collectTemplateDependencies = exports.extractExpression = void 0;
|
|
5
5
|
/**
|
|
6
|
-
* This file is a visitor that checks TaggedTemplateExpressions and look for
|
|
6
|
+
* This file is a visitor that checks TaggedTemplateExpressions and look for WYW template literals.
|
|
7
7
|
* For each template it makes a list of dependencies, try to evaluate expressions, and if it is not possible, mark them as lazy dependencies.
|
|
8
8
|
*/
|
|
9
9
|
const template_1 = require("@babel/template");
|
|
@@ -95,7 +95,7 @@ function hoistIdentifier(idPath) {
|
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Only an expression that can be evaluated in the root scope can be
|
|
98
|
-
* used in a
|
|
98
|
+
* used in a WYW template. This function tries to hoist the expression.
|
|
99
99
|
* @param ex The expression to hoist.
|
|
100
100
|
* @param evaluate If true, we try to statically evaluate the expression.
|
|
101
101
|
* @param imports All the imports of the file.
|
|
@@ -6,9 +6,9 @@ const path_1 = require("path");
|
|
|
6
6
|
const core_1 = require("@babel/core");
|
|
7
7
|
const helper_module_imports_1 = require("@babel/helper-module-imports");
|
|
8
8
|
const processor_utils_1 = require("@wyw-in-js/processor-utils");
|
|
9
|
+
const shared_1 = require("@wyw-in-js/shared");
|
|
9
10
|
const collectExportsAndImports_1 = require("./collectExportsAndImports");
|
|
10
11
|
const collectTemplateDependencies_1 = require("./collectTemplateDependencies");
|
|
11
|
-
const findPackageJSON_1 = require("./findPackageJSON");
|
|
12
12
|
const getSource_1 = require("./getSource");
|
|
13
13
|
const isNotNull_1 = require("./isNotNull");
|
|
14
14
|
const scopeHelpers_1 = require("./scopeHelpers");
|
|
@@ -36,7 +36,7 @@ const getDefinedTagsFromPackage = (pkgName, filename) => {
|
|
|
36
36
|
if (definedTagsCache.has(pkgName)) {
|
|
37
37
|
return definedTagsCache.get(pkgName);
|
|
38
38
|
}
|
|
39
|
-
const packageJSONPath = (0,
|
|
39
|
+
const packageJSONPath = (0, shared_1.findPackageJSON)(pkgName, filename);
|
|
40
40
|
if (!packageJSONPath) {
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function
|
|
3
|
+
function hasWywPreval(exports) {
|
|
4
4
|
if (!exports || typeof exports !== 'object') {
|
|
5
5
|
return false;
|
|
6
6
|
}
|
|
7
|
-
return '
|
|
7
|
+
return '__wywPreval' in exports;
|
|
8
8
|
}
|
|
9
|
-
exports.default =
|
|
9
|
+
exports.default = hasWywPreval;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadLinariaOptions.js","names":["cosmiconfigSync","shaker","searchPlaces","explorerSync","cache","WeakMap","defaultOverrides","nodeModulesRegExp","loadLinariaOptions","overrides","has","get","configFile","ignore","rules","babelOptions","rest","result","undefined","load","search","defaultFeatures","dangerousCodeRemover","globalCache","happyDOM","softErrors","useBabelConfigs","options","displayName","evaluate","extensions","action","test","filename","code","highPriorityPlugins","config","features","set"],"sources":["../../../src/transform/helpers/loadLinariaOptions.ts"],"sourcesContent":["import { cosmiconfigSync } from 'cosmiconfig';\n\nimport type { FeatureFlags, StrictOptions } from '@wyw-in-js/shared';\n\nimport shaker from '../../shaker';\nimport type { PluginOptions } from '../../types';\n\nconst searchPlaces = [\n `.linariarc`,\n `.linariarc.json`,\n `.linariarc.yaml`,\n `.linariarc.yml`,\n `.linariarc.js`,\n `.linariarc.cjs`,\n `.config/linariarc`,\n `.config/linariarc.json`,\n `.config/linariarc.yaml`,\n `.config/linariarc.yml`,\n `.config/linariarc.js`,\n `.config/linariarc.cjs`,\n `linaria.config.js`,\n `linaria.config.cjs`,\n];\n\nconst explorerSync = cosmiconfigSync('linaria', { searchPlaces });\n\nexport type PartialOptions = Partial<Omit<PluginOptions, 'features'>> & {\n features?: Partial<FeatureFlags>;\n};\n\nconst cache = new WeakMap<Partial<PartialOptions>, StrictOptions>();\nconst defaultOverrides = {};\nconst nodeModulesRegExp = /[\\\\/]node_modules[\\\\/]/;\n\nexport function loadLinariaOptions(\n overrides: PartialOptions = defaultOverrides\n): StrictOptions {\n if (cache.has(overrides)) {\n return cache.get(overrides)!;\n }\n\n const { configFile, ignore, rules, babelOptions = {}, ...rest } = overrides;\n\n const result =\n // eslint-disable-next-line no-nested-ternary\n configFile === false\n ? undefined\n : configFile !== undefined\n ? explorerSync.load(configFile)\n : explorerSync.search();\n\n const defaultFeatures: FeatureFlags = {\n dangerousCodeRemover: true,\n globalCache: true,\n happyDOM: true,\n softErrors: false,\n useBabelConfigs: true,\n };\n\n const options: StrictOptions = {\n displayName: false,\n evaluate: true,\n extensions: ['.cjs', '.cts', '.js', '.jsx', '.mjs', '.mts', '.ts', '.tsx'],\n rules: rules ?? [\n {\n action: shaker,\n },\n {\n // The old `ignore` option is used as a default value for `ignore` rule.\n test: ignore ?? nodeModulesRegExp,\n action: 'ignore',\n },\n {\n // Do not ignore ES-modules\n test: (filename, code) => {\n if (!nodeModulesRegExp.test(filename)) {\n return false;\n }\n\n // If a file contains `export` or `import` keywords, we assume it's an ES-module\n return /(?:^|\\*\\/|;)\\s*(?:export|import)\\s/m.test(code);\n },\n action: shaker,\n },\n ],\n babelOptions,\n highPriorityPlugins: ['module-resolver'],\n ...(result ? result.config : {}),\n ...rest,\n features: {\n ...defaultFeatures,\n ...(result ? result.config.features : {}),\n ...rest.features,\n },\n };\n\n cache.set(overrides, options);\n\n return options;\n}\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,aAAa;AAI7C,OAAOC,MAAM,MAAM,cAAc;AAGjC,MAAMC,YAAY,GAAG,CAClB,YAAW,EACX,iBAAgB,EAChB,iBAAgB,EAChB,gBAAe,EACf,eAAc,EACd,gBAAe,EACf,mBAAkB,EAClB,wBAAuB,EACvB,wBAAuB,EACvB,uBAAsB,EACtB,sBAAqB,EACrB,uBAAsB,EACtB,mBAAkB,EAClB,oBAAmB,CACrB;AAED,MAAMC,YAAY,GAAGH,eAAe,CAAC,SAAS,EAAE;EAAEE;AAAa,CAAC,CAAC;AAMjE,MAAME,KAAK,GAAG,IAAIC,OAAO,CAAyC,CAAC;AACnE,MAAMC,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAMC,iBAAiB,GAAG,wBAAwB;AAElD,OAAO,SAASC,kBAAkBA,CAChCC,SAAyB,GAAGH,gBAAgB,EAC7B;EACf,IAAIF,KAAK,CAACM,GAAG,CAACD,SAAS,CAAC,EAAE;IACxB,OAAOL,KAAK,CAACO,GAAG,CAACF,SAAS,CAAC;EAC7B;EAEA,MAAM;IAAEG,UAAU;IAAEC,MAAM;IAAEC,KAAK;IAAEC,YAAY,GAAG,CAAC,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGP,SAAS;EAE3E,MAAMQ,MAAM;EACV;EACAL,UA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C,KAAK,CAACkC,GAAG,CAAC7B,SAAS,EAAEkB,OAAO,CAAC;EAE7B,OAAOA,OAAO;AAChB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addIdentifierToLinariaPreval.js","names":["createId","reference","getOrAddLinariaPreval","scope","rootScope","getProgramParent","programPath","path","object","getData","node","sourceType","prevalExport","expression","type","operator","left","computed","property","right","properties","inserted","pushContainer","get","declaration","declarations","id","init","kind","specifiers","setData","addIdentifierToLinariaPreval","name","newProperty","key","value","shorthand"],"sources":["../../src/utils/addIdentifierToLinariaPreval.ts"],"sourcesContent":["import type { NodePath, Scope } from '@babel/traverse';\nimport type {\n ExportNamedDeclaration,\n ExpressionStatement,\n Identifier,\n ObjectExpression,\n ObjectProperty,\n Program,\n} from '@babel/types';\n\nimport { createId } from './createId';\nimport { reference } from './scopeHelpers';\n\nexport function getOrAddLinariaPreval(\n scope: Scope\n): NodePath<ObjectExpression> {\n const rootScope = scope.getProgramParent();\n const programPath = rootScope.path as NodePath<Program>;\n\n let object = programPath.getData('__linariaPreval');\n if (object) {\n return object;\n }\n\n if (programPath.node.sourceType === 'script') {\n // CJS exports.__linariaPreval = {};\n const prevalExport: ExpressionStatement = {\n expression: {\n type: 'AssignmentExpression',\n operator: '=',\n left: {\n computed: false,\n object: createId('exports'),\n property: createId('__linariaPreval'),\n type: 'MemberExpression',\n },\n right: {\n properties: [],\n type: 'ObjectExpression',\n },\n },\n type: 'ExpressionStatement',\n };\n\n const [inserted] = programPath.pushContainer('body', [prevalExport]);\n object = inserted.get('expression.right') as NodePath<ObjectExpression>;\n } else {\n // ESM export const __linariaPreval = {};\n const prevalExport: ExportNamedDeclaration = {\n declaration: {\n declarations: [\n {\n id: createId('__linariaPreval'),\n init: {\n properties: [],\n type: 'ObjectExpression',\n },\n type: 'VariableDeclarator',\n },\n ],\n kind: 'const',\n type: 'VariableDeclaration',\n },\n specifiers: [],\n type: 'ExportNamedDeclaration',\n };\n\n const [inserted] = programPath.pushContainer('body', [prevalExport]);\n object = inserted.get(\n 'declaration.declarations.0.init'\n ) as NodePath<ObjectExpression>;\n }\n\n programPath.setData('__linariaPreval', object);\n return object;\n}\n\nexport function addIdentifierToLinariaPreval(scope: Scope, name: string) {\n const rootScope = scope.getProgramParent();\n const object = getOrAddLinariaPreval(rootScope);\n const newProperty: ObjectProperty = {\n type: 'ObjectProperty',\n key: createId(name),\n value: createId(name),\n computed: false,\n shorthand: false,\n };\n\n const [inserted] = object.pushContainer('properties', [newProperty]);\n reference(inserted.get('value') as NodePath<Identifier>);\n}\n"],"mappings":"AAUA,SAASA,QAAQ,QAAQ,YAAY;AACrC,SAASC,SAAS,QAAQ,gBAAgB;AAE1C,OAAO,SAASC,qBAAqBA,CACnCC,KAAY,EACgB;EAC5B,MAAMC,SAAS,GAAGD,KAAK,CAACE,gBAAgB,CAAC,CAAC;EAC1C,MAAMC,WAAW,GAAGF,SAAS,CAACG,IAAyB;EAEvD,IAAIC,MAAM,GAAGF,WAAW,CAACG,OAAO,CAAC,iBAAiB,CAAC;EACnD,IAAID,MAAM,EAAE;IACV,OAAOA,MAAM;EACf;EAEA,IAAIF,WAAW,CAACI,IAAI,CAACC,UAAU,KAAK,QAAQ,EAAE;IAC5C;IACA,MAAMC,YAAiC,GAAG;MACxCC,UAAU,EAAE;QACVC,IAAI,EAAE,sBAAsB;QAC5BC,QAAQ,EAAE,GAAG;QACbC,IAAI,EAAE;UACJC,QAAQ,EAAE,KAAK;UACfT,MAAM,EAAER,QAAQ,CAAC,SAAS,CAAC;UAC3BkB,QAAQ,EAAElB,QAAQ,CAAC,iBAAiB,CAAC;UACrCc,IAAI,EAAE;QACR,CAAC;QACDK,KAAK,EAAE;UACLC,UAAU,EAAE,EAAE;UACdN,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC;IAED,MAAM,CAACO,QAAQ,CAAC,GAAGf,WAAW,CAACgB,aAAa,CAAC,MAAM,EAAE,CAACV,YAAY,CAAC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C1D"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { dirname, isAbsolute } from 'path';
|
|
2
|
-
import * as process from 'process';
|
|
3
|
-
import findUp from 'find-up';
|
|
4
|
-
const cache = new Map();
|
|
5
|
-
export function findPackageJSON(pkgName, filename) {
|
|
6
|
-
try {
|
|
7
|
-
// Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined
|
|
8
|
-
const isJest = Boolean(process.env.JEST_WORKER_ID);
|
|
9
|
-
const skipPathsOptions = isJest && !pkgName.startsWith('.');
|
|
10
|
-
const pkgPath = pkgName === '.' && filename && isAbsolute(filename) ? filename : require.resolve(pkgName, filename && !skipPathsOptions ? {
|
|
11
|
-
paths: [dirname(filename)]
|
|
12
|
-
} : {});
|
|
13
|
-
if (!cache.has(pkgPath)) {
|
|
14
|
-
cache.set(pkgPath, findUp.sync('package.json', {
|
|
15
|
-
cwd: pkgPath
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
return cache.get(pkgPath);
|
|
19
|
-
} catch (er) {
|
|
20
|
-
if (typeof er === 'object' && er !== null && er.code === 'MODULE_NOT_FOUND') {
|
|
21
|
-
return undefined;
|
|
22
|
-
}
|
|
23
|
-
throw er;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=findPackageJSON.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findPackageJSON.js","names":["dirname","isAbsolute","process","findUp","cache","Map","findPackageJSON","pkgName","filename","isJest","Boolean","env","JEST_WORKER_ID","skipPathsOptions","startsWith","pkgPath","require","resolve","paths","has","set","sync","cwd","get","er","code","undefined"],"sources":["../../src/utils/findPackageJSON.ts"],"sourcesContent":["import { dirname, isAbsolute } from 'path';\nimport * as process from 'process';\n\nimport findUp from 'find-up';\n\nconst cache = new Map<string, string | undefined>();\n\nexport function findPackageJSON(\n pkgName: string,\n filename: string | null | undefined\n) {\n try {\n // Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined\n const isJest = Boolean(process.env.JEST_WORKER_ID);\n const skipPathsOptions = isJest && !pkgName.startsWith('.');\n\n const pkgPath =\n pkgName === '.' && filename && isAbsolute(filename)\n ? filename\n : require.resolve(\n pkgName,\n filename && !skipPathsOptions ? { paths: [dirname(filename)] } : {}\n );\n if (!cache.has(pkgPath)) {\n cache.set(pkgPath, findUp.sync('package.json', { cwd: pkgPath }));\n }\n\n return cache.get(pkgPath);\n } catch (er: unknown) {\n if (\n typeof er === 'object' &&\n er !== null &&\n (er as { code?: unknown }).code === 'MODULE_NOT_FOUND'\n ) {\n return undefined;\n }\n\n throw er;\n }\n}\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,UAAU,QAAQ,MAAM;AAC1C,OAAO,KAAKC,OAAO,MAAM,SAAS;AAElC,OAAOC,MAAM,MAAM,SAAS;AAE5B,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAA6B,CAAC;AAEnD,OAAO,SAASC,eAAeA,CAC7BC,OAAe,EACfC,QAAmC,EACnC;EACA,IAAI;IACF;IACA,MAAMC,MAAM,GAAGC,OAAO,CAACR,OAAO,CAACS,GAAG,CAACC,cAAc,CAAC;IAClD,MAAMC,gBAAgB,GAAGJ,MAAM,IAAI,CAACF,OAAO,CAACO,UAAU,CAAC,GAAG,CAAC;IAE3D,MAAMC,OAAO,GACXR,OAAO,KAAK,GAAG,IAAIC,QAAQ,IAAIP,UAAU,CAACO,QAAQ,CAAC,GAC/CA,QAAQ,GACRQ,OAAO,CAACC,OAAO,CACbV,OAAO,EACPC,QAAQ,IAAI,CAACK,gBAAgB,GAAG;MAAEK,KAAK,EAAE,CAAClB,OAAO,CAACQ,QAAQ,CAAC;IAAE,CAAC,GAAG,CAAC,CACpE,CAAC;IACP,IAAI,CAACJ,KAAK,CAACe,GAAG,CAACJ,OAAO,CAAC,EAAE;MACvBX,KAAK,CAACgB,GAAG,CAACL,OAAO,EAAEZ,MAAM,CAACkB,IAAI,CAAC,cAAc,EAAE;QAAEC,GAAG,EAAEP;MAAQ,CAAC,CAAC,CAAC;IACnE;IAEA,OAAOX,KAAK,CAACmB,GAAG,CAACR,OAAO,CAAC;EAC3B,CAAC,CAAC,OAAOS,EAAW,EAAE;IACpB,IACE,OAAOA,EAAE,KAAK,QAAQ,IACtBA,EAAE,KAAK,IAAI,IACVA,EAAE,CAAwBC,IAAI,KAAK,kBAAkB,EACtD;MACA,OAAOC,SAAS;IAClB;IAEA,MAAMF,EAAE;EACV;AACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hasLinariaPreval.js","names":["hasLinariaPreval","exports"],"sources":["../../src/utils/hasLinariaPreval.ts"],"sourcesContent":["import type { Value } from '@wyw-in-js/processor-utils';\n\nexport default function hasLinariaPreval(exports: unknown): exports is {\n __linariaPreval: Record<string, () => Value> | null | undefined;\n} {\n if (!exports || typeof exports !== 'object') {\n return false;\n }\n\n return '__linariaPreval' in exports;\n}\n"],"mappings":"AAEA,eAAe,SAASA,gBAAgBA,CAACC,OAAgB,EAEvD;EACA,IAAI,CAACA,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC3C,OAAO,KAAK;EACd;EAEA,OAAO,iBAAiB,IAAIA,OAAO;AACrC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"loadLinariaOptions.js","names":["_cosmiconfig","require","_shaker","_interopRequireDefault","obj","__esModule","default","searchPlaces","explorerSync","cosmiconfigSync","cache","WeakMap","defaultOverrides","nodeModulesRegExp","loadLinariaOptions","overrides","has","get","configFile","ignore","rules","babelOptions","rest","result","undefined","load","search","defaultFeatures","dangerousCodeRemover","globalCache","happyDOM","softErrors","useBabelConfigs","options","displayName","evaluate","extensions","action","shaker","test","filename","code","highPriorityPlugins","config","features","set"],"sources":["../../../src/transform/helpers/loadLinariaOptions.ts"],"sourcesContent":["import { cosmiconfigSync } from 'cosmiconfig';\n\nimport type { FeatureFlags, StrictOptions } from '@wyw-in-js/shared';\n\nimport shaker from '../../shaker';\nimport type { PluginOptions } from '../../types';\n\nconst searchPlaces = [\n `.linariarc`,\n `.linariarc.json`,\n `.linariarc.yaml`,\n `.linariarc.yml`,\n `.linariarc.js`,\n `.linariarc.cjs`,\n `.config/linariarc`,\n `.config/linariarc.json`,\n `.config/linariarc.yaml`,\n `.config/linariarc.yml`,\n `.config/linariarc.js`,\n `.config/linariarc.cjs`,\n `linaria.config.js`,\n `linaria.config.cjs`,\n];\n\nconst explorerSync = cosmiconfigSync('linaria', { searchPlaces });\n\nexport type PartialOptions = Partial<Omit<PluginOptions, 'features'>> & {\n features?: Partial<FeatureFlags>;\n};\n\nconst cache = new WeakMap<Partial<PartialOptions>, StrictOptions>();\nconst defaultOverrides = {};\nconst nodeModulesRegExp = /[\\\\/]node_modules[\\\\/]/;\n\nexport function loadLinariaOptions(\n overrides: PartialOptions = defaultOverrides\n): StrictOptions {\n if (cache.has(overrides)) {\n return cache.get(overrides)!;\n }\n\n const { configFile, ignore, rules, babelOptions = {}, ...rest } = overrides;\n\n const result =\n // eslint-disable-next-line no-nested-ternary\n configFile === false\n ? undefined\n : configFile !== undefined\n ? explorerSync.load(configFile)\n : explorerSync.search();\n\n const defaultFeatures: FeatureFlags = {\n dangerousCodeRemover: true,\n globalCache: true,\n happyDOM: true,\n softErrors: false,\n useBabelConfigs: true,\n };\n\n const options: StrictOptions = {\n displayName: false,\n evaluate: true,\n extensions: ['.cjs', '.cts', '.js', '.jsx', '.mjs', '.mts', '.ts', '.tsx'],\n rules: rules ?? [\n {\n action: shaker,\n },\n {\n // The old `ignore` option is used as a default value for `ignore` rule.\n test: ignore ?? nodeModulesRegExp,\n action: 'ignore',\n },\n {\n // Do not ignore ES-modules\n test: (filename, code) => {\n if (!nodeModulesRegExp.test(filename)) {\n return false;\n }\n\n // If a file contains `export` or `import` keywords, we assume it's an ES-module\n return /(?:^|\\*\\/|;)\\s*(?:export|import)\\s/m.test(code);\n },\n action: shaker,\n },\n ],\n babelOptions,\n highPriorityPlugins: ['module-resolver'],\n ...(result ? result.config : {}),\n ...rest,\n features: {\n ...defaultFeatures,\n ...(result ? result.config.features : {}),\n ...rest.features,\n },\n };\n\n cache.set(overrides, options);\n\n return options;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAkC,SAAAE,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAGlC,MAAMG,YAAY,GAAG,CAClB,YAAW,EACX,iBAAgB,EAChB,iBAAgB,EAChB,gBAAe,EACf,eAAc,EACd,gBAAe,EACf,mBAAkB,EAClB,wBAAuB,EACvB,wBAAuB,EACvB,uBAAsB,EACtB,sBAAqB,EACrB,uBAAsB,EACtB,mBAAkB,EAClB,oBAAmB,CACrB;AAED,MAAMC,YAAY,GAAG,IAAAC,4BAAe,EAAC,SAAS,EAAE;EAAEF;AAAa,CAAC,CAAC;AAMjE,MAAMG,KAAK,GAAG,IAAIC,OAAO,CAAyC,CAAC;AACnE,MAAMC,gBAAgB,GAAG,CAAC,CAAC;AAC3B,MAAMC,iBAAiB,GAAG,wBAAwB;AAE3C,SAASC,kBAAkBA,CAChCC,SAAyB,GAAGH,gBAAgB,EAC7B;EACf,IAAIF,KAAK,CAACM,GAAG,CAACD,SAAS,CAAC,EAAE;IACxB,OAAOL,KAAK,CAACO,GAAG,CAACF,SAAS,CAAC;EAC7B;EAEA,MAAM;IAAEG,UAAU;IAAEC,MAAM;IAAEC,KAAK;IAAEC,YAAY,GAAG,CAAC,CAAC;IAAE,GAAGC;EAAK,CAAC,GAAGP,SAAS;EAE3E,MAAMQ,MAAM;EACV;EACAL,UAAU,KAAK,KAAK,GAChBM,SAAS,GACTN,UAAU,KAAKM,SAAS,GACxBhB,YAAY,CAACiB,IAAI,CAACP,UAAU,CAAC,GAC7BV,YAAY,CAACkB,MAAM,CAAC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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"addIdentifierToLinariaPreval.js","names":["_createId","require","_scopeHelpers","getOrAddLinariaPreval","scope","rootScope","getProgramParent","programPath","path","object","getData","node","sourceType","prevalExport","expression","type","operator","left","computed","createId","property","right","properties","inserted","pushContainer","get","declaration","declarations","id","init","kind","specifiers","setData","addIdentifierToLinariaPreval","name","newProperty","key","value","shorthand","reference"],"sources":["../../src/utils/addIdentifierToLinariaPreval.ts"],"sourcesContent":["import type { NodePath, Scope } from '@babel/traverse';\nimport type {\n ExportNamedDeclaration,\n ExpressionStatement,\n Identifier,\n ObjectExpression,\n ObjectProperty,\n Program,\n} from '@babel/types';\n\nimport { createId } from './createId';\nimport { reference } from './scopeHelpers';\n\nexport function getOrAddLinariaPreval(\n scope: Scope\n): NodePath<ObjectExpression> {\n const rootScope = scope.getProgramParent();\n const programPath = rootScope.path as NodePath<Program>;\n\n let object = programPath.getData('__linariaPreval');\n if (object) {\n return object;\n }\n\n if (programPath.node.sourceType === 'script') {\n // CJS exports.__linariaPreval = {};\n const prevalExport: ExpressionStatement = {\n expression: {\n type: 'AssignmentExpression',\n operator: '=',\n left: {\n computed: false,\n object: createId('exports'),\n property: createId('__linariaPreval'),\n type: 'MemberExpression',\n },\n right: {\n properties: [],\n type: 'ObjectExpression',\n },\n },\n type: 'ExpressionStatement',\n };\n\n const [inserted] = programPath.pushContainer('body', [prevalExport]);\n object = inserted.get('expression.right') as NodePath<ObjectExpression>;\n } else {\n // ESM export const __linariaPreval = {};\n const prevalExport: ExportNamedDeclaration = {\n declaration: {\n declarations: [\n {\n id: createId('__linariaPreval'),\n init: {\n properties: [],\n type: 'ObjectExpression',\n },\n type: 'VariableDeclarator',\n },\n ],\n kind: 'const',\n type: 'VariableDeclaration',\n },\n specifiers: [],\n type: 'ExportNamedDeclaration',\n };\n\n const [inserted] = programPath.pushContainer('body', [prevalExport]);\n object = inserted.get(\n 'declaration.declarations.0.init'\n ) as NodePath<ObjectExpression>;\n }\n\n programPath.setData('__linariaPreval', object);\n return object;\n}\n\nexport function addIdentifierToLinariaPreval(scope: Scope, name: string) {\n const rootScope = scope.getProgramParent();\n const object = getOrAddLinariaPreval(rootScope);\n const newProperty: ObjectProperty = {\n type: 'ObjectProperty',\n key: createId(name),\n value: createId(name),\n computed: false,\n shorthand: false,\n };\n\n const [inserted] = object.pushContainer('properties', [newProperty]);\n reference(inserted.get('value') as NodePath<Identifier>);\n}\n"],"mappings":";;;;;;;AAUA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAEO,SAASE,qBAAqBA,CACnCC,KAAY,EACgB;EAC5B,MAAMC,SAAS,GAAGD,KAAK,CAACE,gBAAgB,CAAC,CAAC;EAC1C,MAAMC,WAAW,GAAGF,SAAS,CAACG,IAAyB;EAEvD,IAAIC,MAAM,GAAGF,WAAW,CAACG,OAAO,CAAC,iBAAiB,CAAC;EACnD,IAAID,MAAM,EAAE;IACV,OAAOA,MAAM;EACf;EAEA,IAAIF,WAAW,CAACI,IAAI,CAACC,UAAU,KAAK,QAAQ,EAAE;IAC5C;IACA,MAAMC,YAAiC,GAAG;MACxCC,UAAU,EAAE;QACVC,IAAI,EAAE,sBAAsB;QAC5BC,QAAQ,EAAE,GAAG;QACbC,IAAI,EAAE;UACJC,QAAQ,EAAE,KAAK;UACfT,MAAM,EAAE,IAAAU,kBAAQ,EAAC,SAAS,CAAC;UAC3BC,QAAQ,EAAE,IAAAD,kBAAQ,EAAC,iBAAiB,CAAC;UACrCJ,IAAI,EAAE;QACR,CAAC;QACDM,KAAK,EAAE;UACLC,UAAU,EAAE,EAAE;UACdP,IAAI,EAAE;QACR;MACF,CAAC;MACDA,IAAI,EAAE;IACR,CAAC;IAED,MAAM,CAACQ,QAAQ,CAAC,GAAGhB,WAAW,CAACiB,aAAa,CAAC,MAAM,EAAE,CAACX,YAAY,CAAC,CAAC;IACpEJ,MAAM,GAAGc,QAAQ,CAACE,GAAG,CA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,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.findPackageJSON = findPackageJSON;
|
|
7
|
-
var _path = require("path");
|
|
8
|
-
var process = _interopRequireWildcard(require("process"));
|
|
9
|
-
var _findUp = _interopRequireDefault(require("find-up"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
-
const cache = new Map();
|
|
14
|
-
function findPackageJSON(pkgName, filename) {
|
|
15
|
-
try {
|
|
16
|
-
// Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined
|
|
17
|
-
const isJest = Boolean(process.env.JEST_WORKER_ID);
|
|
18
|
-
const skipPathsOptions = isJest && !pkgName.startsWith('.');
|
|
19
|
-
const pkgPath = pkgName === '.' && filename && (0, _path.isAbsolute)(filename) ? filename : require.resolve(pkgName, filename && !skipPathsOptions ? {
|
|
20
|
-
paths: [(0, _path.dirname)(filename)]
|
|
21
|
-
} : {});
|
|
22
|
-
if (!cache.has(pkgPath)) {
|
|
23
|
-
cache.set(pkgPath, _findUp.default.sync('package.json', {
|
|
24
|
-
cwd: pkgPath
|
|
25
|
-
}));
|
|
26
|
-
}
|
|
27
|
-
return cache.get(pkgPath);
|
|
28
|
-
} catch (er) {
|
|
29
|
-
if (typeof er === 'object' && er !== null && er.code === 'MODULE_NOT_FOUND') {
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
throw er;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
//# sourceMappingURL=findPackageJSON.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"findPackageJSON.js","names":["_path","require","process","_interopRequireWildcard","_findUp","_interopRequireDefault","obj","__esModule","default","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","Map","findPackageJSON","pkgName","filename","isJest","Boolean","env","JEST_WORKER_ID","skipPathsOptions","startsWith","pkgPath","isAbsolute","resolve","paths","dirname","findUp","sync","cwd","er","code","undefined"],"sources":["../../src/utils/findPackageJSON.ts"],"sourcesContent":["import { dirname, isAbsolute } from 'path';\nimport * as process from 'process';\n\nimport findUp from 'find-up';\n\nconst cache = new Map<string, string | undefined>();\n\nexport function findPackageJSON(\n pkgName: string,\n filename: string | null | undefined\n) {\n try {\n // Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined\n const isJest = Boolean(process.env.JEST_WORKER_ID);\n const skipPathsOptions = isJest && !pkgName.startsWith('.');\n\n const pkgPath =\n pkgName === '.' && filename && isAbsolute(filename)\n ? filename\n : require.resolve(\n pkgName,\n filename && !skipPathsOptions ? { paths: [dirname(filename)] } : {}\n );\n if (!cache.has(pkgPath)) {\n cache.set(pkgPath, findUp.sync('package.json', { cwd: pkgPath }));\n }\n\n return cache.get(pkgPath);\n } catch (er: unknown) {\n if (\n typeof er === 'object' &&\n er !== null &&\n (er as { code?: unknown }).code === 'MODULE_NOT_FOUND'\n ) {\n return undefined;\n }\n\n throw er;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAC,uBAAA,CAAAF,OAAA;AAEA,IAAAG,OAAA,GAAAC,sBAAA,CAAAJ,OAAA;AAA6B,SAAAI,uBAAAC,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAAA,SAAAG,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAP,wBAAAG,GAAA,EAAAI,WAAA,SAAAA,WAAA,IAAAJ,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAQ,KAAA,GAAAL,wBAAA,CAAAC,WAAA,OAAAI,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAT,GAAA,YAAAQ,KAAA,CAAAE,GAAA,CAAAV,GAAA,SAAAW,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAhB,GAAA,QAAAgB,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAnB,GAAA,EAAAgB,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAf,GAAA,EAAAgB,GAAA,cAAAI,IAAA,KAAAA,IAAA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AK,kBAAkB,EACtD;MACA,OAAOC,SAAS;IAClB;IAEA,MAAMF,EAAE;EACV;AACF"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = hasLinariaPreval;
|
|
7
|
-
function hasLinariaPreval(exports) {
|
|
8
|
-
if (!exports || typeof exports !== 'object') {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
return '__linariaPreval' in exports;
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=hasLinariaPreval.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hasLinariaPreval.js","names":["hasLinariaPreval","exports"],"sources":["../../src/utils/hasLinariaPreval.ts"],"sourcesContent":["import type { Value } from '@wyw-in-js/processor-utils';\n\nexport default function hasLinariaPreval(exports: unknown): exports is {\n __linariaPreval: Record<string, () => Value> | null | undefined;\n} {\n if (!exports || typeof exports !== 'object') {\n return false;\n }\n\n return '__linariaPreval' in exports;\n}\n"],"mappings":";;;;;;AAEe,SAASA,gBAAgBA,CAACC,OAAgB,EAEvD;EACA,IAAI,CAACA,OAAO,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC3C,OAAO,KAAK;EACd;EAEA,OAAO,iBAAiB,IAAIA,OAAO;AACrC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { NodePath, Scope } from '@babel/traverse';
|
|
2
|
-
import type { ObjectExpression } from '@babel/types';
|
|
3
|
-
export declare function getOrAddLinariaPreval(scope: Scope): NodePath<ObjectExpression>;
|
|
4
|
-
export declare function addIdentifierToLinariaPreval(scope: Scope, name: string): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function findPackageJSON(pkgName: string, filename: string | null | undefined): string | undefined;
|
|
@@ -1,56 +0,0 @@
|
|
|
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 (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.findPackageJSON = void 0;
|
|
30
|
-
const path_1 = require("path");
|
|
31
|
-
const process = __importStar(require("process"));
|
|
32
|
-
const find_up_1 = __importDefault(require("find-up"));
|
|
33
|
-
const cache = new Map();
|
|
34
|
-
function findPackageJSON(pkgName, filename) {
|
|
35
|
-
try {
|
|
36
|
-
// Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined
|
|
37
|
-
const isJest = Boolean(process.env.JEST_WORKER_ID);
|
|
38
|
-
const skipPathsOptions = isJest && !pkgName.startsWith('.');
|
|
39
|
-
const pkgPath = pkgName === '.' && filename && (0, path_1.isAbsolute)(filename)
|
|
40
|
-
? filename
|
|
41
|
-
: require.resolve(pkgName, filename && !skipPathsOptions ? { paths: [(0, path_1.dirname)(filename)] } : {});
|
|
42
|
-
if (!cache.has(pkgPath)) {
|
|
43
|
-
cache.set(pkgPath, find_up_1.default.sync('package.json', { cwd: pkgPath }));
|
|
44
|
-
}
|
|
45
|
-
return cache.get(pkgPath);
|
|
46
|
-
}
|
|
47
|
-
catch (er) {
|
|
48
|
-
if (typeof er === 'object' &&
|
|
49
|
-
er !== null &&
|
|
50
|
-
er.code === 'MODULE_NOT_FOUND') {
|
|
51
|
-
return undefined;
|
|
52
|
-
}
|
|
53
|
-
throw er;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.findPackageJSON = findPackageJSON;
|