@absolutejs/absolute 0.19.0-beta.42 → 0.19.0-beta.44

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