@absolutejs/absolute 0.19.0-beta.25 → 0.19.0-beta.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/build.js CHANGED
@@ -202161,20 +202161,13 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, TRANSPILABLE, REACT_EXTENSIONS, escape
202161
202161
  return { dynamicRegex, fromRegex, lookup, sideEffectRegex };
202162
202162
  }, rewriteImports2 = (code, filePath, projectRoot, rewriter) => {
202163
202163
  let result = code;
202164
- if (rewriter) {
202165
- const replacer = (_match, prefix, specifier, suffix) => {
202166
- const webPath = rewriter.lookup.get(specifier);
202167
- if (!webPath)
202168
- return _match;
202164
+ const bareSpecifierRe = /((?:from|import)\s*["'])([^"'./][^"']*)(["'])/g;
202165
+ result = result.replace(bareSpecifierRe, (_match, prefix, specifier, suffix) => {
202166
+ const webPath = rewriter?.lookup.get(specifier);
202167
+ if (webPath)
202169
202168
  return `${prefix}${webPath}${suffix}`;
202170
- };
202171
- rewriter.fromRegex.lastIndex = 0;
202172
- rewriter.sideEffectRegex.lastIndex = 0;
202173
- rewriter.dynamicRegex.lastIndex = 0;
202174
- result = result.replace(rewriter.fromRegex, replacer);
202175
- result = result.replace(rewriter.sideEffectRegex, replacer);
202176
- result = result.replace(rewriter.dynamicRegex, replacer);
202177
- }
202169
+ return `${prefix}/@stub/${encodeURIComponent(specifier)}${suffix}`;
202170
+ });
202178
202171
  const fileDir = dirname7(filePath);
202179
202172
  result = result.replace(/(from\s*["'])(\.\.?\/[^"']+)(["'])/g, (_match, prefix, relPath, suffix) => {
202180
202173
  const absPath = resolve16(fileDir, relPath);
@@ -202281,7 +202274,29 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, TRANSPILABLE, REACT_EXTENSIONS, escape
202281
202274
  }, createModuleServer = (config) => {
202282
202275
  const { projectRoot, vendorPaths } = config;
202283
202276
  const rewriter = buildImportRewriter(vendorPaths);
202284
- return (pathname) => {
202277
+ return async (pathname) => {
202278
+ if (pathname.startsWith("/@stub/")) {
202279
+ const specifier = decodeURIComponent(pathname.slice("/@stub/".length));
202280
+ let stubCode = `export default {};
202281
+ `;
202282
+ try {
202283
+ const mod = await import(specifier);
202284
+ const names = Object.keys(mod).filter((k) => k !== "default" && k !== "__esModule");
202285
+ if (names.length > 0) {
202286
+ const noops = names.map((n) => `export const ${n} = () => {};`).join(`
202287
+ `);
202288
+ stubCode = `${noops}
202289
+ export default {};
202290
+ `;
202291
+ }
202292
+ } catch {}
202293
+ return new Response(stubCode, {
202294
+ headers: {
202295
+ "Cache-Control": "public, max-age=31536000, immutable",
202296
+ "Content-Type": "application/javascript"
202297
+ }
202298
+ });
202299
+ }
202285
202300
  if (!pathname.startsWith(SRC_PREFIX))
202286
202301
  return;
202287
202302
  const relPath = pathname.slice(SRC_PREFIX.length);
@@ -204094,5 +204109,5 @@ export {
204094
204109
  build
204095
204110
  };
204096
204111
 
204097
- //# debugId=DB5958D70D4EF7CA64756E2164756E21
204112
+ //# debugId=939786484821A09864756E2164756E21
204098
204113
  //# sourceMappingURL=build.js.map