@absolutejs/absolute 0.19.0-beta.43 → 0.19.0-beta.45

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/build.js CHANGED
@@ -202203,16 +202203,29 @@ ${stubs}
202203
202203
  return { dynamicRegex, fromRegex, lookup, sideEffectRegex };
202204
202204
  }, rewriteImports2 = (code, filePath, projectRoot, rewriter) => {
202205
202205
  let result = code;
202206
- const rewriteBare = (_match, prefix, specifier, suffix) => {
202207
- const webPath = rewriter?.lookup.get(specifier);
202208
- if (webPath)
202206
+ if (rewriter) {
202207
+ const replacer = (_match, prefix, specifier, suffix) => {
202208
+ const webPath = rewriter.lookup.get(specifier);
202209
+ if (!webPath)
202210
+ return _match;
202209
202211
  return `${prefix}${webPath}${suffix}`;
202212
+ };
202213
+ rewriter.fromRegex.lastIndex = 0;
202214
+ rewriter.sideEffectRegex.lastIndex = 0;
202215
+ rewriter.dynamicRegex.lastIndex = 0;
202216
+ result = result.replace(rewriter.fromRegex, replacer);
202217
+ result = result.replace(rewriter.sideEffectRegex, replacer);
202218
+ result = result.replace(rewriter.dynamicRegex, replacer);
202219
+ }
202220
+ const stubReplace = (_match, prefix, specifier, suffix) => {
202221
+ if (specifier.startsWith("/") || specifier.startsWith("."))
202222
+ return _match;
202210
202223
  return `${prefix}/@stub/${encodeURIComponent(specifier)}${suffix}`;
202211
202224
  };
202212
- result = result.replace(/^(import\s+.+?\s+from\s*["'])([^"'./][^"']*)(["'])/gm, rewriteBare);
202213
- result = result.replace(/^(import\s*["'])([^"'./][^"']*)(["'])/gm, rewriteBare);
202214
- result = result.replace(/^(export\s+.+?\s+from\s*["'])([^"'./][^"']*)(["'])/gm, rewriteBare);
202215
- result = result.replace(/(import\s*\(\s*["'])([^"'./][^"']*)(["']\s*\))/g, rewriteBare);
202225
+ result = result.replace(/^(import\s+.+?\s+from\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
202226
+ result = result.replace(/^(import\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
202227
+ result = result.replace(/^(export\s+.+?\s+from\s*["'])([^"'./][^"']*)(["'])/gm, stubReplace);
202228
+ result = result.replace(/(import\s*\(\s*["'])([^"'./][^"']*)(["']\s*\))/g, stubReplace);
202216
202229
  const fileDir = dirname7(filePath);
202217
202230
  result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => {
202218
202231
  const absPath = resolve16(fileDir, relPath);
@@ -204219,5 +204232,5 @@ export {
204219
204232
  build
204220
204233
  };
204221
204234
 
204222
- //# debugId=74CEC5A7E19325F564756E2164756E21
204235
+ //# debugId=5C01F5FC328A260164756E2164756E21
204223
204236
  //# sourceMappingURL=build.js.map