piral-core 1.6.1-beta.7294 → 1.6.2-beta.7367

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.
Files changed (2) hide show
  1. package/lib/codegen.js +170 -112
  2. package/package.json +4 -4
package/lib/codegen.js CHANGED
@@ -865,13 +865,13 @@ var require_CachedInputFileSystem = __commonJS({
865
865
  callback = options;
866
866
  options = void 0;
867
867
  }
868
+ if (typeof path !== "string" && !Buffer.isBuffer(path) && !(path instanceof URL) && typeof path !== "number") {
869
+ callback(new TypeError("path must be a string, Buffer, URL or number"));
870
+ return;
871
+ }
868
872
  if (options) {
869
873
  return this._provider.call(this._providerContext, path, options, callback);
870
874
  }
871
- if (typeof path !== "string") {
872
- callback(new TypeError("path must be a string"));
873
- return;
874
- }
875
875
  let callbacks = this._activeAsyncOperations.get(path);
876
876
  if (callbacks) {
877
877
  callbacks.push(callback);
@@ -921,68 +921,70 @@ var require_CachedInputFileSystem = __commonJS({
921
921
  callback = options;
922
922
  options = void 0;
923
923
  }
924
- if (typeof path !== "string") {
925
- callback(new TypeError("path must be a string"));
924
+ if (typeof path !== "string" && !Buffer.isBuffer(path) && !(path instanceof URL) && typeof path !== "number") {
925
+ callback(new TypeError("path must be a string, Buffer, URL or number"));
926
926
  return;
927
927
  }
928
+ const strPath = typeof path !== "string" ? path.toString() : path;
928
929
  if (options) {
929
930
  return this._provider.call(this._providerContext, path, options, callback);
930
931
  }
931
932
  if (this._mode === STORAGE_MODE_SYNC) {
932
933
  this._enterAsyncMode();
933
934
  }
934
- let cacheEntry = this._data.get(path);
935
+ let cacheEntry = this._data.get(strPath);
935
936
  if (cacheEntry !== void 0) {
936
937
  if (cacheEntry.err)
937
938
  return nextTick(callback, cacheEntry.err);
938
939
  return nextTick(callback, null, cacheEntry.result);
939
940
  }
940
- let callbacks = this._activeAsyncOperations.get(path);
941
+ let callbacks = this._activeAsyncOperations.get(strPath);
941
942
  if (callbacks !== void 0) {
942
943
  callbacks.push(callback);
943
944
  return;
944
945
  }
945
- this._activeAsyncOperations.set(path, callbacks = [callback]);
946
+ this._activeAsyncOperations.set(strPath, callbacks = [callback]);
946
947
  this._provider.call(this._providerContext, path, (err, result) => {
947
- this._activeAsyncOperations.delete(path);
948
- this._storeResult(path, err, result);
948
+ this._activeAsyncOperations.delete(strPath);
949
+ this._storeResult(strPath, err, result);
949
950
  this._enterAsyncMode();
950
951
  runCallbacks(callbacks, err, result);
951
952
  });
952
953
  }
953
954
  provideSync(path, options) {
954
- if (typeof path !== "string") {
955
+ if (typeof path !== "string" && !Buffer.isBuffer(path) && !(path instanceof URL) && typeof path !== "number") {
955
956
  throw new TypeError("path must be a string");
956
957
  }
958
+ const strPath = typeof path !== "string" ? path.toString() : path;
957
959
  if (options) {
958
960
  return this._syncProvider.call(this._providerContext, path, options);
959
961
  }
960
962
  if (this._mode === STORAGE_MODE_SYNC) {
961
963
  this._runDecays();
962
964
  }
963
- let cacheEntry = this._data.get(path);
965
+ let cacheEntry = this._data.get(strPath);
964
966
  if (cacheEntry !== void 0) {
965
967
  if (cacheEntry.err)
966
968
  throw cacheEntry.err;
967
969
  return cacheEntry.result;
968
970
  }
969
- const callbacks = this._activeAsyncOperations.get(path);
970
- this._activeAsyncOperations.delete(path);
971
+ const callbacks = this._activeAsyncOperations.get(strPath);
972
+ this._activeAsyncOperations.delete(strPath);
971
973
  let result;
972
974
  try {
973
975
  result = this._syncProvider.call(this._providerContext, path);
974
976
  } catch (err) {
975
- this._storeResult(path, err, void 0);
977
+ this._storeResult(strPath, err, void 0);
976
978
  this._enterSyncModeWhenIdle();
977
979
  if (callbacks) {
978
980
  runCallbacks(callbacks, err, void 0);
979
981
  }
980
982
  throw err;
981
983
  }
982
- this._storeResult(path, void 0, result);
984
+ this._storeResult(strPath, null, result);
983
985
  this._enterSyncModeWhenIdle();
984
986
  if (callbacks) {
985
- runCallbacks(callbacks, void 0, result);
987
+ runCallbacks(callbacks, null, result);
986
988
  }
987
989
  return result;
988
990
  }
@@ -995,9 +997,10 @@ var require_CachedInputFileSystem = __commonJS({
995
997
  }
996
998
  this._enterIdleMode();
997
999
  }
998
- } else if (typeof what === "string") {
1000
+ } else if (typeof what === "string" || Buffer.isBuffer(what) || what instanceof URL || typeof what === "number") {
1001
+ const strWhat = typeof what !== "string" ? what.toString() : what;
999
1002
  for (let [key, data] of this._data) {
1000
- if (key.startsWith(what)) {
1003
+ if (key.startsWith(strWhat)) {
1001
1004
  this._data.delete(key);
1002
1005
  data.level.delete(key);
1003
1006
  }
@@ -1008,7 +1011,8 @@ var require_CachedInputFileSystem = __commonJS({
1008
1011
  } else {
1009
1012
  for (let [key, data] of this._data) {
1010
1013
  for (const item of what) {
1011
- if (key.startsWith(item)) {
1014
+ const strItem = typeof item !== "string" ? item.toString() : item;
1015
+ if (key.startsWith(strItem)) {
1012
1016
  this._data.delete(key);
1013
1017
  data.level.delete(key);
1014
1018
  break;
@@ -1023,12 +1027,14 @@ var require_CachedInputFileSystem = __commonJS({
1023
1027
  purgeParent(what) {
1024
1028
  if (!what) {
1025
1029
  this.purge();
1026
- } else if (typeof what === "string") {
1027
- this.purge(dirname2(what));
1030
+ } else if (typeof what === "string" || Buffer.isBuffer(what) || what instanceof URL || typeof what === "number") {
1031
+ const strWhat = typeof what !== "string" ? what.toString() : what;
1032
+ this.purge(dirname2(strWhat));
1028
1033
  } else {
1029
1034
  const set = new Set();
1030
1035
  for (const item of what) {
1031
- set.add(dirname2(item));
1036
+ const strItem = typeof item !== "string" ? item.toString() : item;
1037
+ set.add(dirname2(strItem));
1032
1038
  }
1033
1039
  this.purge(set);
1034
1040
  }
@@ -1154,6 +1160,11 @@ var require_CachedInputFileSystem = __commonJS({
1154
1160
  this.readlink = readlink;
1155
1161
  const readlinkSync = this._readlinkBackend.provideSync;
1156
1162
  this.readlinkSync = readlinkSync;
1163
+ this._realpathBackend = createBackend(duration, this.fileSystem.realpath, this.fileSystem.realpathSync, this.fileSystem);
1164
+ const realpath = this._realpathBackend.provide;
1165
+ this.realpath = realpath;
1166
+ const realpathSync = this._realpathBackend.provideSync;
1167
+ this.realpathSync = realpathSync;
1157
1168
  }
1158
1169
  purge(what) {
1159
1170
  this._statBackend.purge(what);
@@ -1162,6 +1173,7 @@ var require_CachedInputFileSystem = __commonJS({
1162
1173
  this._readFileBackend.purge(what);
1163
1174
  this._readlinkBackend.purge(what);
1164
1175
  this._readJsonBackend.purge(what);
1176
+ this._realpathBackend.purge(what);
1165
1177
  }
1166
1178
  };
1167
1179
  }
@@ -2413,6 +2425,10 @@ var require_path = __commonJS({
2413
2425
  Internal: 5
2414
2426
  });
2415
2427
  exports.PathType = PathType;
2428
+ var invalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))?(\\|\/|$)/i;
2429
+ exports.invalidSegmentRegEx = invalidSegmentRegEx;
2430
+ var deprecatedInvalidSegmentRegEx = /(^|\\|\/)((\.|%2e)(\.|%2e)?|(n|%6e|%4e)(o|%6f|%4f)(d|%64|%44)(e|%65|%45)(_|%5f)(m|%6d|%4d)(o|%6f|%4f)(d|%64|%44)(u|%75|%55)(l|%6c|%4c)(e|%65|%45)(s|%73|%53))(\\|\/|$)/i;
2431
+ exports.deprecatedInvalidSegmentRegEx = deprecatedInvalidSegmentRegEx;
2416
2432
  var getType = (p) => {
2417
2433
  switch (p.length) {
2418
2434
  case 0:
@@ -2545,30 +2561,6 @@ var require_path = __commonJS({
2545
2561
  return cacheEntry;
2546
2562
  };
2547
2563
  exports.cachedJoin = cachedJoin;
2548
- var checkImportsExportsFieldTarget = (relativePath) => {
2549
- let lastNonSlashIndex = 0;
2550
- let slashIndex = relativePath.indexOf("/", 1);
2551
- let cd = 0;
2552
- while (slashIndex !== -1) {
2553
- const folder = relativePath.slice(lastNonSlashIndex, slashIndex);
2554
- switch (folder) {
2555
- case "..": {
2556
- cd--;
2557
- if (cd < 0)
2558
- return new Error(`Trying to access out of package scope. Requesting ${relativePath}`);
2559
- break;
2560
- }
2561
- case ".":
2562
- break;
2563
- default:
2564
- cd++;
2565
- break;
2566
- }
2567
- lastNonSlashIndex = slashIndex + 1;
2568
- slashIndex = relativePath.indexOf("/", lastNonSlashIndex);
2569
- }
2570
- };
2571
- exports.checkImportsExportsFieldTarget = checkImportsExportsFieldTarget;
2572
2564
  }
2573
2565
  });
2574
2566
 
@@ -2772,7 +2764,8 @@ var require_Resolver = __commonJS({
2772
2764
  }
2773
2765
  newStack.add(stackEntry);
2774
2766
  } else {
2775
- newStack = new Set([stackEntry]);
2767
+ newStack = new Set();
2768
+ newStack.add(stackEntry);
2776
2769
  }
2777
2770
  this.hooks.resolveStep.call(hook, request);
2778
2771
  if (hook.isUsed()) {
@@ -2852,7 +2845,7 @@ var require_SyncAsyncFileSystemDecorator = __commonJS({
2852
2845
  this.lstat = (arg, options, callback) => {
2853
2846
  let result;
2854
2847
  try {
2855
- result = lstatSync.call(fs2, arg);
2848
+ result = callback ? lstatSync.call(fs2, arg, options) : lstatSync.call(fs2, arg);
2856
2849
  } catch (e) {
2857
2850
  return (callback || options)(e);
2858
2851
  }
@@ -2873,7 +2866,7 @@ var require_SyncAsyncFileSystemDecorator = __commonJS({
2873
2866
  this.readdir = (arg, options, callback) => {
2874
2867
  let result;
2875
2868
  try {
2876
- result = fs2.readdirSync(arg);
2869
+ result = callback ? fs2.readdirSync(arg, options) : fs2.readdirSync(arg);
2877
2870
  } catch (e) {
2878
2871
  return (callback || options)(e);
2879
2872
  }
@@ -2883,7 +2876,7 @@ var require_SyncAsyncFileSystemDecorator = __commonJS({
2883
2876
  this.readFile = (arg, options, callback) => {
2884
2877
  let result;
2885
2878
  try {
2886
- result = fs2.readFileSync(arg);
2879
+ result = callback ? fs2.readFileSync(arg, options) : fs2.readFileSync(arg);
2887
2880
  } catch (e) {
2888
2881
  return (callback || options)(e);
2889
2882
  }
@@ -2893,7 +2886,7 @@ var require_SyncAsyncFileSystemDecorator = __commonJS({
2893
2886
  this.readlink = (arg, options, callback) => {
2894
2887
  let result;
2895
2888
  try {
2896
- result = fs2.readlinkSync(arg);
2889
+ result = callback ? fs2.readlinkSync(arg, options) : fs2.readlinkSync(arg);
2897
2890
  } catch (e) {
2898
2891
  return (callback || options)(e);
2899
2892
  }
@@ -2904,16 +2897,31 @@ var require_SyncAsyncFileSystemDecorator = __commonJS({
2904
2897
  this.readJsonSync = void 0;
2905
2898
  const readJsonSync = fs2.readJsonSync;
2906
2899
  if (readJsonSync) {
2907
- this.readJson = (arg, options, callback) => {
2900
+ this.readJson = (arg, callback) => {
2908
2901
  let result;
2909
2902
  try {
2910
2903
  result = readJsonSync.call(fs2, arg);
2904
+ } catch (e) {
2905
+ return callback(e);
2906
+ }
2907
+ callback(null, result);
2908
+ };
2909
+ this.readJsonSync = (arg) => readJsonSync.call(fs2, arg);
2910
+ }
2911
+ this.realpath = void 0;
2912
+ this.realpathSync = void 0;
2913
+ const realpathSync = fs2.realpathSync;
2914
+ if (realpathSync) {
2915
+ this.realpath = (arg, options, callback) => {
2916
+ let result;
2917
+ try {
2918
+ result = callback ? realpathSync.call(fs2, arg, options) : realpathSync.call(fs2, arg);
2911
2919
  } catch (e) {
2912
2920
  return (callback || options)(e);
2913
2921
  }
2914
2922
  (callback || options)(null, result);
2915
2923
  };
2916
- this.readJsonSync = (arg, options) => readJsonSync.call(fs2, arg, options);
2924
+ this.realpathSync = (arg, options) => realpathSync.call(fs2, arg, options);
2917
2925
  }
2918
2926
  }
2919
2927
  module2.exports = SyncAsyncFileSystemDecorator;
@@ -2932,7 +2940,7 @@ var require_forEachBail = __commonJS({
2932
2940
  let loop = void 0;
2933
2941
  iterator(array[i++], (err, result) => {
2934
2942
  if (err || result !== void 0 || i >= array.length) {
2935
- return callback(err, result);
2943
+ return callback(err, result, i);
2936
2944
  }
2937
2945
  if (loop === false)
2938
2946
  while (next())
@@ -3398,6 +3406,7 @@ var require_DirectoryExistsPlugin = __commonJS({
3398
3406
  var require_entrypoints = __commonJS({
3399
3407
  "../../../node_modules/enhanced-resolve/lib/util/entrypoints.js"(exports, module2) {
3400
3408
  "use strict";
3409
+ var { parseIdentifier } = require_identifier();
3401
3410
  var slashCode = "/".charCodeAt(0);
3402
3411
  var dotCode = ".".charCodeAt(0);
3403
3412
  var hashCode = "#".charCodeAt(0);
@@ -3406,24 +3415,27 @@ var require_entrypoints = __commonJS({
3406
3415
  return createFieldProcessor(buildExportsField(exportsField), (request) => request.length === 0 ? "." : "./" + request, assertExportsFieldRequest, assertExportTarget);
3407
3416
  };
3408
3417
  module2.exports.processImportsField = function processImportsField(importsField) {
3409
- return createFieldProcessor(buildImportsField(importsField), (request) => "#" + request, assertImportsFieldRequest, assertImportTarget);
3418
+ return createFieldProcessor(importsField, (request) => "#" + request, assertImportsFieldRequest, assertImportTarget);
3410
3419
  };
3411
3420
  function createFieldProcessor(field, normalizeRequest, assertRequest, assertTarget) {
3412
3421
  return function fieldProcessor(request, conditionNames) {
3413
3422
  request = assertRequest(request);
3414
3423
  const match = findMatch(normalizeRequest(request), field);
3415
3424
  if (match === null)
3416
- return [];
3417
- const [mapping, remainingRequest, isSubpathMapping, isPattern] = match;
3425
+ return [[], null];
3426
+ const [mapping, remainingRequest, isSubpathMapping, isPattern, usedField] = match;
3418
3427
  let direct = null;
3419
3428
  if (isConditionalMapping(mapping)) {
3420
3429
  direct = conditionalMapping(mapping, conditionNames);
3421
3430
  if (direct === null)
3422
- return [];
3431
+ return [[], null];
3423
3432
  } else {
3424
3433
  direct = mapping;
3425
3434
  }
3426
- return directMapping(remainingRequest, isPattern, isSubpathMapping, direct, conditionNames, assertTarget);
3435
+ return [
3436
+ directMapping(remainingRequest, isPattern, isSubpathMapping, direct, conditionNames, assertTarget),
3437
+ usedField
3438
+ ];
3427
3439
  };
3428
3440
  }
3429
3441
  function assertExportsFieldRequest(request) {
@@ -3456,16 +3468,23 @@ var require_entrypoints = __commonJS({
3456
3468
  return request.slice(1);
3457
3469
  }
3458
3470
  function assertExportTarget(exp, expectFolder) {
3459
- if (exp.charCodeAt(0) === slashCode || exp.charCodeAt(0) === dotCode && exp.charCodeAt(1) !== slashCode) {
3460
- throw new Error(`Export should be relative path and start with "./", got ${JSON.stringify(exp)}.`);
3471
+ const parsedIdentifier = parseIdentifier(exp);
3472
+ if (!parsedIdentifier) {
3473
+ return;
3461
3474
  }
3462
- const isFolder = exp.charCodeAt(exp.length - 1) === slashCode;
3475
+ const [relativePath] = parsedIdentifier;
3476
+ const isFolder = relativePath.charCodeAt(relativePath.length - 1) === slashCode;
3463
3477
  if (isFolder !== expectFolder) {
3464
3478
  throw new Error(expectFolder ? `Expecting folder to folder mapping. ${JSON.stringify(exp)} should end with "/"` : `Expecting file to file mapping. ${JSON.stringify(exp)} should not end with "/"`);
3465
3479
  }
3466
3480
  }
3467
3481
  function assertImportTarget(imp, expectFolder) {
3468
- const isFolder = imp.charCodeAt(imp.length - 1) === slashCode;
3482
+ const parsedIdentifier = parseIdentifier(imp);
3483
+ if (!parsedIdentifier) {
3484
+ return;
3485
+ }
3486
+ const [relativePath] = parsedIdentifier;
3487
+ const isFolder = relativePath.charCodeAt(relativePath.length - 1) === slashCode;
3469
3488
  if (isFolder !== expectFolder) {
3470
3489
  throw new Error(expectFolder ? `Expecting folder to folder mapping. ${JSON.stringify(imp)} should end with "/"` : `Expecting file to file mapping. ${JSON.stringify(imp)} should not end with "/"`);
3471
3490
  }
@@ -3492,7 +3511,7 @@ var require_entrypoints = __commonJS({
3492
3511
  function findMatch(request, field) {
3493
3512
  if (Object.prototype.hasOwnProperty.call(field, request) && !request.includes("*") && !request.endsWith("/")) {
3494
3513
  const target2 = field[request];
3495
- return [target2, "", false, false];
3514
+ return [target2, "", false, false, request];
3496
3515
  }
3497
3516
  let bestMatch = "";
3498
3517
  let bestMatchSubpath;
@@ -3520,7 +3539,8 @@ var require_entrypoints = __commonJS({
3520
3539
  target,
3521
3540
  bestMatchSubpath,
3522
3541
  isSubpathMapping,
3523
- isPattern
3542
+ isPattern,
3543
+ bestMatch
3524
3544
  ];
3525
3545
  }
3526
3546
  function isConditionalMapping(mapping) {
@@ -3571,14 +3591,9 @@ var require_entrypoints = __commonJS({
3571
3591
  loop:
3572
3592
  while (lookup.length > 0) {
3573
3593
  const [mapping, conditions, j] = lookup[lookup.length - 1];
3574
- const last = conditions.length - 1;
3575
3594
  for (let i = j; i < conditions.length; i++) {
3576
3595
  const condition = conditions[i];
3577
- if (i !== last) {
3578
- if (condition === "default") {
3579
- throw new Error("Default condition should be last one");
3580
- }
3581
- } else if (condition === "default") {
3596
+ if (condition === "default") {
3582
3597
  const innerMapping = mapping[condition];
3583
3598
  if (isConditionalMapping(innerMapping)) {
3584
3599
  const conditionalMapping2 = innerMapping;
@@ -3632,22 +3647,6 @@ var require_entrypoints = __commonJS({
3632
3647
  }
3633
3648
  return field;
3634
3649
  }
3635
- function buildImportsField(field) {
3636
- const keys = Object.keys(field);
3637
- for (let i = 0; i < keys.length; i++) {
3638
- const key = keys[i];
3639
- if (key.charCodeAt(0) !== hashCode) {
3640
- throw new Error(`Imports field key should start with "#" (key: ${JSON.stringify(key)})`);
3641
- }
3642
- if (key.length === 1) {
3643
- throw new Error(`Imports field key should have at least 2 characters (key: ${JSON.stringify(key)})`);
3644
- }
3645
- if (key.charCodeAt(1) === slashCode) {
3646
- throw new Error(`Imports field key should not start with "#/" (key: ${JSON.stringify(key)})`);
3647
- }
3648
- }
3649
- return field;
3650
- }
3651
3650
  }
3652
3651
  });
3653
3652
 
@@ -3655,12 +3654,14 @@ var require_entrypoints = __commonJS({
3655
3654
  var require_ExportsFieldPlugin = __commonJS({
3656
3655
  "../../../node_modules/enhanced-resolve/lib/ExportsFieldPlugin.js"(exports, module2) {
3657
3656
  "use strict";
3658
- var path = require("path");
3659
3657
  var DescriptionFileUtils = require_DescriptionFileUtils();
3660
3658
  var forEachBail = require_forEachBail();
3661
3659
  var { processExportsField } = require_entrypoints();
3662
3660
  var { parseIdentifier } = require_identifier();
3663
- var { checkImportsExportsFieldTarget } = require_path();
3661
+ var {
3662
+ invalidSegmentRegEx,
3663
+ deprecatedInvalidSegmentRegEx
3664
+ } = require_path();
3664
3665
  module2.exports = class ExportsFieldPlugin {
3665
3666
  constructor(source, conditionNames, fieldNamePath, target) {
3666
3667
  this.source = source;
@@ -3684,13 +3685,14 @@ var require_ExportsFieldPlugin = __commonJS({
3684
3685
  return callback(new Error(`Resolving to directories is not possible with the exports field (request was ${remainingRequest}/)`));
3685
3686
  }
3686
3687
  let paths;
3688
+ let usedField;
3687
3689
  try {
3688
3690
  let fieldProcessor = this.fieldProcessorCache.get(request.descriptionFileData);
3689
3691
  if (fieldProcessor === void 0) {
3690
3692
  fieldProcessor = processExportsField(exportsField);
3691
3693
  this.fieldProcessorCache.set(request.descriptionFileData, fieldProcessor);
3692
3694
  }
3693
- paths = fieldProcessor(remainingRequest, this.conditionNames);
3695
+ [paths, usedField] = fieldProcessor(remainingRequest, this.conditionNames);
3694
3696
  } catch (err) {
3695
3697
  if (resolveContext.log) {
3696
3698
  resolveContext.log(`Exports field in ${request.descriptionFilePath} can't be processed: ${err}`);
@@ -3700,24 +3702,38 @@ var require_ExportsFieldPlugin = __commonJS({
3700
3702
  if (paths.length === 0) {
3701
3703
  return callback(new Error(`Package path ${remainingRequest} is not exported from package ${request.descriptionFileRoot} (see exports field in ${request.descriptionFilePath})`));
3702
3704
  }
3703
- forEachBail(paths, (p, callback2) => {
3705
+ forEachBail(paths, (p, callback2, i) => {
3704
3706
  const parsedIdentifier = parseIdentifier(p);
3705
3707
  if (!parsedIdentifier)
3706
3708
  return callback2();
3707
3709
  const [relativePath, query, fragment] = parsedIdentifier;
3708
- const error = checkImportsExportsFieldTarget(relativePath);
3709
- if (error) {
3710
- return callback2(error);
3710
+ if (relativePath.length === 0 || !relativePath.startsWith("./")) {
3711
+ if (paths.length === i) {
3712
+ return callback2(new Error(`Invalid "exports" target "${p}" defined for "${usedField}" in the package config ${request.descriptionFilePath}, targets must start with "./"`));
3713
+ }
3714
+ return callback2();
3715
+ }
3716
+ if (invalidSegmentRegEx.exec(relativePath.slice(2)) !== null && deprecatedInvalidSegmentRegEx.test(relativePath.slice(2)) !== null) {
3717
+ if (paths.length === i) {
3718
+ return callback2(new Error(`Invalid "exports" target "${p}" defined for "${usedField}" in the package config ${request.descriptionFilePath}, targets must start with "./"`));
3719
+ }
3720
+ return callback2();
3711
3721
  }
3712
3722
  const obj = {
3713
3723
  ...request,
3714
3724
  request: void 0,
3715
- path: path.join(request.descriptionFileRoot, relativePath),
3725
+ path: resolver.join(request.descriptionFileRoot, relativePath),
3716
3726
  relativePath,
3717
3727
  query,
3718
3728
  fragment
3719
3729
  };
3720
- resolver.doResolve(target, obj, "using exports field: " + p, resolveContext, callback2);
3730
+ resolver.doResolve(target, obj, "using exports field: " + p, resolveContext, (err, result) => {
3731
+ if (err)
3732
+ return callback2(err);
3733
+ if (result === void 0)
3734
+ return callback2(null, null);
3735
+ callback2(null, result);
3736
+ });
3721
3737
  }, (err, result) => callback(err, result || null));
3722
3738
  });
3723
3739
  }
@@ -3829,12 +3845,14 @@ var require_FileExistsPlugin = __commonJS({
3829
3845
  var require_ImportsFieldPlugin = __commonJS({
3830
3846
  "../../../node_modules/enhanced-resolve/lib/ImportsFieldPlugin.js"(exports, module2) {
3831
3847
  "use strict";
3832
- var path = require("path");
3833
3848
  var DescriptionFileUtils = require_DescriptionFileUtils();
3834
3849
  var forEachBail = require_forEachBail();
3835
3850
  var { processImportsField } = require_entrypoints();
3836
3851
  var { parseIdentifier } = require_identifier();
3837
- var { checkImportsExportsFieldTarget } = require_path();
3852
+ var {
3853
+ invalidSegmentRegEx,
3854
+ deprecatedInvalidSegmentRegEx
3855
+ } = require_path();
3838
3856
  var dotCode = ".".charCodeAt(0);
3839
3857
  module2.exports = class ImportsFieldPlugin {
3840
3858
  constructor(source, conditionNames, fieldNamePath, targetFile, targetPackage) {
@@ -3860,13 +3878,14 @@ var require_ImportsFieldPlugin = __commonJS({
3860
3878
  return callback(new Error(`Resolving to directories is not possible with the imports field (request was ${remainingRequest}/)`));
3861
3879
  }
3862
3880
  let paths;
3881
+ let usedField;
3863
3882
  try {
3864
3883
  let fieldProcessor = this.fieldProcessorCache.get(request.descriptionFileData);
3865
3884
  if (fieldProcessor === void 0) {
3866
3885
  fieldProcessor = processImportsField(importsField);
3867
3886
  this.fieldProcessorCache.set(request.descriptionFileData, fieldProcessor);
3868
3887
  }
3869
- paths = fieldProcessor(remainingRequest, this.conditionNames);
3888
+ [paths, usedField] = fieldProcessor(remainingRequest, this.conditionNames);
3870
3889
  } catch (err) {
3871
3890
  if (resolveContext.log) {
3872
3891
  resolveContext.log(`Imports field in ${request.descriptionFilePath} can't be processed: ${err}`);
@@ -3876,26 +3895,34 @@ var require_ImportsFieldPlugin = __commonJS({
3876
3895
  if (paths.length === 0) {
3877
3896
  return callback(new Error(`Package import ${remainingRequest} is not imported from package ${request.descriptionFileRoot} (see imports field in ${request.descriptionFilePath})`));
3878
3897
  }
3879
- forEachBail(paths, (p, callback2) => {
3898
+ forEachBail(paths, (p, callback2, i) => {
3880
3899
  const parsedIdentifier = parseIdentifier(p);
3881
3900
  if (!parsedIdentifier)
3882
3901
  return callback2();
3883
3902
  const [path_, query, fragment] = parsedIdentifier;
3884
- const error = checkImportsExportsFieldTarget(path_);
3885
- if (error) {
3886
- return callback2(error);
3887
- }
3888
3903
  switch (path_.charCodeAt(0)) {
3889
3904
  case dotCode: {
3905
+ if (invalidSegmentRegEx.exec(path_.slice(2)) !== null && deprecatedInvalidSegmentRegEx.test(path_.slice(2)) !== null) {
3906
+ if (paths.length === i) {
3907
+ return callback2(new Error(`Invalid "imports" target "${p}" defined for "${usedField}" in the package config ${request.descriptionFilePath}, targets must start with "./"`));
3908
+ }
3909
+ return callback2();
3910
+ }
3890
3911
  const obj = {
3891
3912
  ...request,
3892
3913
  request: void 0,
3893
- path: path.join(request.descriptionFileRoot, path_),
3914
+ path: resolver.join(request.descriptionFileRoot, path_),
3894
3915
  relativePath: path_,
3895
3916
  query,
3896
3917
  fragment
3897
3918
  };
3898
- resolver.doResolve(targetFile, obj, "using imports field: " + p, resolveContext, callback2);
3919
+ resolver.doResolve(targetFile, obj, "using imports field: " + p, resolveContext, (err, result) => {
3920
+ if (err)
3921
+ return callback2(err);
3922
+ if (result === void 0)
3923
+ return callback2(null, null);
3924
+ callback2(null, result);
3925
+ });
3899
3926
  break;
3900
3927
  }
3901
3928
  default: {
@@ -3907,7 +3934,13 @@ var require_ImportsFieldPlugin = __commonJS({
3907
3934
  query,
3908
3935
  fragment
3909
3936
  };
3910
- resolver.doResolve(targetPackage, obj, "using imports field: " + p, resolveContext, callback2);
3937
+ resolver.doResolve(targetPackage, obj, "using imports field: " + p, resolveContext, (err, result) => {
3938
+ if (err)
3939
+ return callback2(err);
3940
+ if (result === void 0)
3941
+ return callback2(null, null);
3942
+ callback2(null, result);
3943
+ });
3911
3944
  }
3912
3945
  }
3913
3946
  }, (err, result) => callback(err, result || null));
@@ -4212,13 +4245,15 @@ var require_PnpPlugin = __commonJS({
4212
4245
  "../../../node_modules/enhanced-resolve/lib/PnpPlugin.js"(exports, module2) {
4213
4246
  "use strict";
4214
4247
  module2.exports = class PnpPlugin {
4215
- constructor(source, pnpApi, target) {
4248
+ constructor(source, pnpApi, target, alternateTarget) {
4216
4249
  this.source = source;
4217
4250
  this.pnpApi = pnpApi;
4218
4251
  this.target = target;
4252
+ this.alternateTarget = alternateTarget;
4219
4253
  }
4220
4254
  apply(resolver) {
4221
4255
  const target = resolver.ensureHook(this.target);
4256
+ const alternateTarget = resolver.ensureHook(this.alternateTarget);
4222
4257
  resolver.getHook(this.source).tapAsync("PnpPlugin", (request, resolveContext, callback) => {
4223
4258
  const req = request.request;
4224
4259
  if (!req)
@@ -4235,6 +4270,16 @@ var require_PnpPlugin = __commonJS({
4235
4270
  resolution = this.pnpApi.resolveToUnqualified(packageName, issuer, {
4236
4271
  considerBuiltins: false
4237
4272
  });
4273
+ if (resolution === null) {
4274
+ resolver.doResolve(alternateTarget, request, "issuer is not managed by a pnpapi", resolveContext, (err, result) => {
4275
+ if (err)
4276
+ return callback(err);
4277
+ if (result)
4278
+ return callback(null, result);
4279
+ return callback(null, null);
4280
+ });
4281
+ return;
4282
+ }
4238
4283
  if (resolveContext.fileDependencies) {
4239
4284
  apiResolution = this.pnpApi.resolveToUnqualified("pnpapi", issuer, {
4240
4285
  considerBuiltins: false
@@ -4643,7 +4688,18 @@ var require_ResolverFactory = __commonJS({
4643
4688
  var UseFilePlugin = require_UseFilePlugin();
4644
4689
  function processPnpApiOption(option) {
4645
4690
  if (option === void 0 && versions.pnp) {
4646
- return require("pnpapi");
4691
+ const _findPnpApi = require("module").findPnpApi;
4692
+ if (_findPnpApi) {
4693
+ return {
4694
+ resolveToUnqualified(request, issuer, opts) {
4695
+ const pnpapi = _findPnpApi(issuer);
4696
+ if (!pnpapi) {
4697
+ return null;
4698
+ }
4699
+ return pnpapi.resolveToUnqualified(request, issuer, opts);
4700
+ }
4701
+ };
4702
+ }
4647
4703
  }
4648
4704
  return option || null;
4649
4705
  }
@@ -4758,6 +4814,7 @@ var require_ResolverFactory = __commonJS({
4758
4814
  resolver.ensureHook("normalResolve");
4759
4815
  resolver.ensureHook("internal");
4760
4816
  resolver.ensureHook("rawModule");
4817
+ resolver.ensureHook("alternateRawModule");
4761
4818
  resolver.ensureHook("module");
4762
4819
  resolver.ensureHook("resolveAsModule");
4763
4820
  resolver.ensureHook("undescribedResolveInPackage");
@@ -4824,7 +4881,8 @@ var require_ResolverFactory = __commonJS({
4824
4881
  if (Array.isArray(item)) {
4825
4882
  if (item.includes("node_modules") && pnpApi) {
4826
4883
  plugins.push(new ModulesInHierarchicalDirectoriesPlugin("raw-module", item.filter((i) => i !== "node_modules"), "module"));
4827
- plugins.push(new PnpPlugin("raw-module", pnpApi, "undescribed-resolve-in-package"));
4884
+ plugins.push(new PnpPlugin("raw-module", pnpApi, "undescribed-resolve-in-package", "alternate-raw-module"));
4885
+ plugins.push(new ModulesInHierarchicalDirectoriesPlugin("alternate-raw-module", ["node_modules"], "module"));
4828
4886
  } else {
4829
4887
  plugins.push(new ModulesInHierarchicalDirectoriesPlugin("raw-module", item, "module"));
4830
4888
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-core",
3
- "version": "1.6.1-beta.7294",
3
+ "version": "1.6.2-beta.7367",
4
4
  "description": "The core library for creating a Piral instance.",
5
5
  "keywords": [
6
6
  "portal",
@@ -62,8 +62,8 @@
62
62
  },
63
63
  "dependencies": {
64
64
  "path-to-regexp": "^1.8.0",
65
- "piral-base": "1.6.1-beta.7294",
66
- "piral-debug-utils": "1.6.1-beta.7294",
65
+ "piral-base": "1.6.2-beta.7367",
66
+ "piral-debug-utils": "1.6.2-beta.7367",
67
67
  "zustand": "^3.0.0"
68
68
  },
69
69
  "devDependencies": {
@@ -83,5 +83,5 @@
83
83
  "react-router-dom",
84
84
  "tslib"
85
85
  ],
86
- "gitHead": "e4ec29aa4e165b7aa5792325829240af2c70ec67"
86
+ "gitHead": "8d7ec61c81bdc200aad2233e8b01f41f9f63264b"
87
87
  }