github web-infra-dev/rspack v2.1.4

8 hours ago

Highlights

Fine-grained import.meta parser options

module.parser.javascript.importMeta now accepts an object so each known import.meta property can be configured independently, on top of the existing true / false / 'preserve-unknown' values. Properties set to false are preserved for runtime evaluation, omitted properties keep their default behavior, and unknown properties are preserved. Both webpack-compatible keys (dirname, filename, main, url, webpack, webpackContext) and Rspack-specific keys (rspackHash, rspackPublicPath, glob, ...) are supported.

export default {
  module: {
    parser: {
      javascript: {
        importMeta: {
          // keep `import.meta.url` for runtime evaluation
          url: false,
          // keep the compile-time replacement of `import.meta.webpack`
          webpack: true,
        },
      },
    },
  },
};

Static worker URL output

module.parser.javascript.worker now accepts an object form with alias and url, alongside the existing boolean and string[] forms. With url: 'new-url-relative' and output.module enabled, Rspack emits a static new URL() expression for new Worker(new URL(..., import.meta.url)) instead of runtime code, honoring output.publicPath and output.workerPublicPath.

export default {
  output: {
    module: true,
    chunkFilename: '[name].bundle.js',
  },
  module: {
    parser: {
      javascript: {
        worker: {
          url: 'new-url-relative',
        },
      },
    },
  },
};
new Worker(new URL('./worker.js', import.meta.url));

// would become 👇
new Worker(new URL('./worker.bundle.js', import.meta.url));

What's Changed

New Features 🎉

Performance 🚀

Bug Fixes 🐞

Refactor 🔨

Other Changes

  • chore(ci): surface Windows Defender status after disable attempt by @stormslowly in #14711
  • chore(ci): read binary-size data via authenticated API by @stormslowly in #14730
  • chore(deps): update patch npm dependencies by @renovate[bot] in #14751
  • chore(deps): update dependency @rslint/core to v0.6.5 by @renovate[bot] in #14749
  • chore(deps): update dependency @module-federation/runtime-tools to v2.7.0 by @renovate[bot] in #14752
  • chore(deps): update dependency webpack-sources to v3.5.1 by @renovate[bot] in #14750
  • revert: "feat: support persistent cache for module hashes" by @ahabhgk in #14763

New Contributors

Full Changelog: v2.1.3...v2.1.4

Don't miss a new rspack release

NewReleases is sending notifications on new releases.