npm @rspack/cli 1.0.0-beta.1
v1.0.0-beta.1

latest releases: 1.1.1, 1.1.0, 1.1.0-beta.0...
3 months ago

Highlights 💡

Import Attributes

Rspack now supports Import Attributes by defaults:

import json from "./foo.json" with { type: "json" };

import("foo.json", { with: { type: "json" } });

PR: #7333

Layers

Rspack now supports module and chunk layers. This feature can be used by frameworks like Rsnext (The Rspack-based Next.js) to implement React Server Components.

  • Example: build modern and legacy bundles at the same time:
export default {
  entry: {
    index: {
      import: './src/index.js',
      layer: 'modern',
    },
    'index-legacy': {
      import: './src/index.js',
      layer: 'legacy',
    },
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        issuerLayer: 'modern',
        use: [
          {
            loader: 'builtin:swc-loader',
            options: {
              env: {
                targets: 'Chrome >= 87',
              },
            },
          },
        ],
      },
      {
        test: /\.js$/,
        issuerLayer: 'legacy',
        use: [
          {
            loader: 'builtin:swc-loader',
            options: {
              env: {
                targets: 'ie >= 11',
              },
            },
          },
        ],
      },
    ],
  },
  experiments: {
    layers: true,
  },
};
  • Example: Customize rules and resolve options for RSC modules
export default {
  module: {
    rules: [
      // set `layer` for some modules
      {
        test: /rsc-modules/,
        layer: 'rsc',
      },
      // set resolve options for specified layer
      {
        issuerLayer: 'rsc',
        resolve: {
          conditionNames: ['react-server', '...'],
        },
      },
      {
        // set loaders for specified layer
        oneOf: [
          {
            issuerLayer: 'rsc',
            test: /\.tsx?$/,
            use: ['some-rsc-loader'],
          },
          {
            test: /\.tsx?$/,
            use: ['some-normal-loader'],
          },
        ],
      },
    ],
  },
  experiments: {
    layers: true,
  },
};

PR: #7330

What's Changed

Performance Improvements ⚡

Exciting New Features 🎉

  • feat: experiments layers by @ahabhgk in #7330
  • feat(css-extract): avoid reloading all CSS when hot load by @shulaoda in #7314
  • feat(modern-module): force concaten single module by @fi3ework in #7317
  • feat: better diagnostic report for harmony dependency by @shulaoda in #7337
  • feat: support parser.importMeta and output.importMetaName by @xc2 in #7231

Bug Fixes 🐞

  • fix: lightningcss-loader targets array not work as expected by @chenjiahan in #7331
  • fix(rspack_plugin_asset): repect user environment config when inlining svg by @SoonIter in #7347
  • fix: rspack errors don't support the correct location by @shulaoda in #7328
  • fix: add runtime condition for harmony reexport checked by @ahabhgk in #7353
  • fix: remove nonsensical intersection types by @colinaaa in #7360
  • fix: builtin:lightningcss-loader shuold keep loader query by @JSerFeng in #7363

Document Updates 📖

Other Changes

New Contributors

Full Changelog: v1.0.0-beta.0...v1.0.0-beta.1

Don't miss a new cli release

NewReleases is sending notifications on new releases.