@rspack-canary/browser 1.7.3-canary-58d41d16-20260115035302 → 1.7.3-canary-1138ed18-20260115124957

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/index.mjs CHANGED
@@ -56337,6 +56337,7 @@ const BuiltinLazyCompilationPlugin = base_create(external_rspack_wasi_browser_js
56337
56337
  client,
56338
56338
  currentActiveModules
56339
56339
  }), 'thisCompilation');
56340
+ var middleware_Buffer = __webpack_require__("./src/browser/buffer.ts")["Buffer"];
56340
56341
  const LAZY_COMPILATION_PREFIX = '/lazy-compilation-using-';
56341
56342
  const getDefaultClient = (compiler)=>require.resolve(`../hot/lazy-compilation-${compiler.options.externalsPresets.node ? 'node' : 'web'}.js`);
56342
56343
  const noop = (_req, _res, next)=>{
@@ -56399,15 +56400,62 @@ function applyPlugin(compiler, options, activeModules) {
56399
56400
  }, options.entries ?? true, options.imports ?? true, `${options.client || getDefaultClient(compiler)}?${encodeURIComponent(getFullServerUrl(options))}`, options.test);
56400
56401
  plugin.apply(compiler);
56401
56402
  }
56403
+ function readModuleIdsFromBody(req) {
56404
+ if (void 0 !== req.body) {
56405
+ if (Array.isArray(req.body)) return Promise.resolve(req.body);
56406
+ if ('string' == typeof req.body) return Promise.resolve(req.body.split('\n').filter(Boolean));
56407
+ throw new Error('Invalid body type');
56408
+ }
56409
+ return new Promise((resolve, reject)=>{
56410
+ if (req.aborted || req.destroyed) return void reject(new Error('Request was aborted before body could be read'));
56411
+ const cleanup = ()=>{
56412
+ req.removeListener('data', onData);
56413
+ req.removeListener('end', onEnd);
56414
+ req.removeListener('error', onError);
56415
+ req.removeListener('close', onClose);
56416
+ req.removeListener('aborted', onAborted);
56417
+ };
56418
+ const chunks = [];
56419
+ const onData = (chunk)=>{
56420
+ chunks.push(chunk);
56421
+ };
56422
+ const onEnd = ()=>{
56423
+ cleanup();
56424
+ const body = middleware_Buffer.concat(chunks).toString('utf8');
56425
+ resolve(body.split('\n').filter(Boolean));
56426
+ };
56427
+ const onError = (err)=>{
56428
+ cleanup();
56429
+ reject(err);
56430
+ };
56431
+ const onClose = ()=>{
56432
+ cleanup();
56433
+ reject(new Error('Request was closed before body could be read'));
56434
+ };
56435
+ const onAborted = ()=>{
56436
+ cleanup();
56437
+ reject(new Error('Request was aborted before body could be read'));
56438
+ };
56439
+ req.on('data', onData);
56440
+ req.on('end', onEnd);
56441
+ req.on('error', onError);
56442
+ req.on('close', onClose);
56443
+ req.on('aborted', onAborted);
56444
+ });
56445
+ }
56402
56446
  const lazyCompilationMiddlewareInternal = (compiler, activeModules, lazyCompilationPrefix)=>{
56403
56447
  const logger = compiler.getInfrastructureLogger('LazyCompilation');
56404
- return (req, res, next)=>{
56405
- if (!req.url?.startsWith(lazyCompilationPrefix)) return next?.();
56406
- const modules = req.url.slice(lazyCompilationPrefix.length).split('@').map(decodeURIComponent);
56407
- req.socket.setNoDelay(true);
56408
- res.setHeader('content-type', 'text/event-stream');
56409
- res.writeHead(200);
56410
- res.write('\n');
56448
+ return async (req, res, next)=>{
56449
+ if (!req.url?.startsWith(lazyCompilationPrefix) || 'POST' !== req.method) return next?.();
56450
+ let modules = [];
56451
+ try {
56452
+ modules = await readModuleIdsFromBody(req);
56453
+ } catch (err) {
56454
+ logger.error('Failed to parse request body: ' + err);
56455
+ res.writeHead(400);
56456
+ res.end('Bad Request');
56457
+ return;
56458
+ }
56411
56459
  const moduleActivated = [];
56412
56460
  for (const key of modules){
56413
56461
  const activated = activeModules.has(key);
@@ -56418,6 +56466,9 @@ const lazyCompilationMiddlewareInternal = (compiler, activeModules, lazyCompilat
56418
56466
  }
56419
56467
  }
56420
56468
  if (moduleActivated.length && compiler.watching) compiler.watching.invalidate();
56469
+ res.writeHead(200);
56470
+ res.write('\n');
56471
+ res.end();
56421
56472
  };
56422
56473
  };
56423
56474
  function MangleExportsPlugin_define_property(obj, key, value) {
@@ -58216,7 +58267,7 @@ const applybundlerInfoDefaults = (rspackFuture, library)=>{
58216
58267
  if ('object' == typeof rspackFuture) {
58217
58268
  D(rspackFuture, 'bundlerInfo', {});
58218
58269
  if ('object' == typeof rspackFuture.bundlerInfo) {
58219
- D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-58d41d16-20260115035302");
58270
+ D(rspackFuture.bundlerInfo, 'version', "1.7.3-canary-1138ed18-20260115124957");
58220
58271
  D(rspackFuture.bundlerInfo, 'bundler', 'rspack');
58221
58272
  D(rspackFuture.bundlerInfo, 'force', !library);
58222
58273
  }
@@ -60486,7 +60537,7 @@ class MultiStats {
60486
60537
  return obj;
60487
60538
  });
60488
60539
  if (childOptions.version) {
60489
- obj.rspackVersion = "1.7.3-canary-58d41d16-20260115035302";
60540
+ obj.rspackVersion = "1.7.3-canary-1138ed18-20260115124957";
60490
60541
  obj.version = "5.75.0";
60491
60542
  }
60492
60543
  if (childOptions.hash) obj.hash = obj.children.map((j)=>j.hash).join('');
@@ -60531,10 +60582,10 @@ class MultiStats {
60531
60582
  this.stats = stats;
60532
60583
  }
60533
60584
  }
60534
- function createChildOptions(options = {}, context) {
60585
+ function createChildOptions(options, context) {
60535
60586
  const { children: childrenOptions, ...baseOptions } = 'string' == typeof options || 'boolean' == typeof options ? {
60536
60587
  preset: options
60537
- } : options;
60588
+ } : options ?? {};
60538
60589
  const children = this.stats.map((stat, idx)=>{
60539
60590
  const childOptions = Array.isArray(childrenOptions) ? childrenOptions[idx] : childrenOptions;
60540
60591
  return stat.compilation.createStatsOptions({
@@ -62318,7 +62369,7 @@ const SIMPLE_EXTRACTORS = {
62318
62369
  },
62319
62370
  version: (object)=>{
62320
62371
  object.version = "5.75.0";
62321
- object.rspackVersion = "1.7.3-canary-58d41d16-20260115035302";
62372
+ object.rspackVersion = "1.7.3-canary-1138ed18-20260115124957";
62322
62373
  },
62323
62374
  env: (object, _compilation, _context, { _env })=>{
62324
62375
  object.env = _env;
@@ -67546,7 +67597,7 @@ function transformSync(source, options) {
67546
67597
  const _options = JSON.stringify(options || {});
67547
67598
  return external_rspack_wasi_browser_js_["default"].transformSync(source, _options);
67548
67599
  }
67549
- const exports_rspackVersion = "1.7.3-canary-58d41d16-20260115035302";
67600
+ const exports_rspackVersion = "1.7.3-canary-1138ed18-20260115124957";
67550
67601
  const exports_version = "5.75.0";
67551
67602
  const exports_WebpackError = Error;
67552
67603
  const sources = __webpack_require__("../../node_modules/.pnpm/webpack-sources@3.3.3_patch_hash=b2a26650f08a2359d0a3cd81fa6fa272aa7441a28dd7e601792da5ed5d2b4aee/node_modules/webpack-sources/lib/index.js");
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack-canary/browser",
3
- "version": "1.7.3-canary-58d41d16-20260115035302",
3
+ "version": "1.7.3-canary-1138ed18-20260115124957",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "Rspack for running in the browser. This is still in early stage and may not follow the semver.",