Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ bun add -D @rspack/dev-middleware
```js
const middleware = require("@rspack/dev-middleware");
const express = require("express");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

const compiler = webpack({
const compiler = rspack({
// webpack options
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
// webpack options
// rspack options

});

Expand Down Expand Up @@ -261,12 +261,12 @@ This option also accepts a `Function` value, which can be used to filter which f
The function follows the same premise as [`Array#filter`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) in which a return value of `false` _will not_ write the file, and a return value of `true` _will_ write the file to disk. eg.

```js
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

const configuration = {
/* Webpack configuration */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
/* Webpack configuration */
/* rspack configuration */

};
const compiler = webpack(configuration);
const compiler = rspack(configuration);

middleware(compiler, {
writeToDisk: (filePath) => /superman\.css$/.test(filePath),
Expand All @@ -289,12 +289,12 @@ This can be done simply by using `path.join`:
const path = require("node:path");
const mkdirp = require("mkdirp");
const myOutputFileSystem = require("my-fs");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

myOutputFileSystem.join = path.join.bind(path); // no need to bind
myOutputFileSystem.mkdirp = mkdirp.bind(mkdirp); // no need to bind

const compiler = webpack({
const compiler = rspack({
/* Webpack configuration */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
/* Webpack configuration */
/* rspack configuration */

});

Expand All @@ -306,12 +306,12 @@ middleware(compiler, { outputFileSystem: myOutputFileSystem });
Allows to set up a callback to change the response data.

```js
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

const configuration = {
/* Webpack configuration */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
/* Webpack configuration */
/* rspack configuration */

};
const compiler = webpack(configuration);
const compiler = rspack(configuration);

middleware(compiler, {
// Note - if you send the `Range` header you will have `ReadStream`
Expand Down Expand Up @@ -344,9 +344,9 @@ A function executed once the middleware has stopped watching.
```js
const middleware = require("@rspack/dev-middleware");
const express = require("express");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

const compiler = webpack({
const compiler = rspack({
/* Webpack configuration */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
/* Webpack configuration */
/* rspack configuration */

});

Expand Down Expand Up @@ -379,9 +379,9 @@ A function executed once the middleware has invalidated.
```js
const middleware = require("@rspack/dev-middleware");
const express = require("express");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

const compiler = webpack({
const compiler = rspack({
/* Webpack configuration */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
/* Webpack configuration */
/* rspack configuration */

});

Expand Down Expand Up @@ -419,9 +419,9 @@ If the bundle is valid at the time of calling, the callback is executed immediat
```js
const middleware = require("@rspack/dev-middleware");
const express = require("express");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

const compiler = webpack({
const compiler = rspack({
/* Webpack configuration */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
/* Webpack configuration */
/* rspack configuration */

});

Expand Down Expand Up @@ -453,9 +453,9 @@ URL for the requested file.
```js
const middleware = require("@rspack/dev-middleware");
const express = require("express");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

const compiler = webpack({
const compiler = rspack({
/* Webpack configuration */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
/* Webpack configuration */
/* rspack configuration */

});

Expand Down Expand Up @@ -484,9 +484,9 @@ But there is a solution to avoid it - mount the middleware to a non-root route,
```js
const middleware = require("@rspack/dev-middleware");
const express = require("express");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

const compiler = webpack({
const compiler = rspack({
// webpack options
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
// webpack options
// rspack options

});

Expand Down Expand Up @@ -526,9 +526,9 @@ Example Implementation:
const middleware = require("@rspack/dev-middleware");
const express = require("express");
const isObject = require("is-object");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");

const compiler = webpack({
const compiler = rspack({
/* Webpack configuration */
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the migration to rspack, this comment should be updated to refer to rspack instead of webpack.

Suggested change
/* Webpack configuration */
/* rspack configuration */

});

Expand Down Expand Up @@ -614,10 +614,10 @@ Examples of use with other servers will follow here.
const http = require("node:http");
const devMiddleware = require("@rspack/dev-middleware");
const connect = require("connect");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");
const webpackConfig = require("./webpack.config.js");

const compiler = webpack(webpackConfig);
const compiler = rspack(webpackConfig);
const devMiddlewareOptions = {
// options
};
Expand All @@ -635,10 +635,10 @@ const http = require("node:http");
const devMiddleware = require("@rspack/dev-middleware");
const finalhandler = require("finalhandler");
const Router = require("router");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");
const webpackConfig = require("./webpack.config.js");

const compiler = webpack(webpackConfig);
const compiler = rspack(webpackConfig);
const devMiddlewareOptions = {
// options
};
Expand All @@ -660,10 +660,10 @@ server.listen(3000);
```js
const devMiddleware = require("@rspack/dev-middleware");
const express = require("express");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");
const webpackConfig = require("./webpack.config.js");

const compiler = webpack(webpackConfig);
const compiler = rspack(webpackConfig);
const devMiddlewareOptions = {
// options
};
Expand All @@ -679,10 +679,10 @@ app.listen(3000, () => console.log("Example app listening on port 3000!"));
```js
const middleware = require("@rspack/dev-middleware");
const Koa = require("koa");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");
const webpackConfig = require("./webpack.simple.config");

const compiler = webpack(webpackConfig);
const compiler = rspack(webpackConfig);
const devMiddlewareOptions = {
// options
};
Expand All @@ -698,10 +698,10 @@ app.listen(3000);
```js
const Hapi = require("@hapi/hapi");
const devMiddleware = require("@rspack/dev-middleware");
const webpack = require("webpack");
const { rspack } = require("@rspack/core");
const webpackConfig = require("./webpack.config.js");

const compiler = webpack(webpackConfig);
const compiler = rspack(webpackConfig);
const devMiddlewareOptions = {};

const server = Hapi.server({ port: 3000, host: "localhost" });
Expand Down Expand Up @@ -732,10 +732,10 @@ Fastify interop will require the use of `fastify-express` instead of `middie` fo
```js
const devMiddleware = require("@rspack/dev-middleware");
const fastify = require("fastify")();
const webpack = require("webpack");
const { rspack } = require("@rspack/core");
const webpackConfig = require("./webpack.config.js");

const compiler = webpack(webpackConfig);
const compiler = rspack(webpackConfig);
const devMiddlewareOptions = {
// options
};
Expand All @@ -751,10 +751,10 @@ await fastify.listen(3000);
import { serve } from "@hono/node-server";
import devMiddleware from "@rspack/dev-middleware";
import { Hono } from "hono";
import webpack from "webpack";
import { rspack } from "@rspack/core";
import webpackConfig from "./webpack.config.js";

const compiler = webpack(webpackConfig);
const compiler = rspack(webpackConfig);
const devMiddlewareOptions = {
// options
};
Expand Down
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ module.exports = {
testMatch: ["**/test/**/*.test.js"],
setupFilesAfterEnv: ["<rootDir>/setupTest.js"],
globalSetup: "<rootDir>/scripts/globalSetup.js",
snapshotResolver: "./test/helpers/snapshotResolver.js",
};
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"range-parser": "^1.2.1"
},
"devDependencies": {
"@rspack/core": "2.0.0-beta.5",
"@babel/cli": "^7.16.7",
"@babel/core": "^7.16.7",
"@babel/preset-env": "^7.16.7",
Expand Down Expand Up @@ -79,14 +80,13 @@
"prettier": "^3.6.0",
"router": "^2.2.0",
"supertest": "^7.0.0",
"typescript": "^5.3.3",
"webpack": "^5.101.0"
"typescript": "^5.3.3"
},
"peerDependencies": {
"webpack": "^5.0.0"
"@rspack/core": "^2.0.0-0"
},
"peerDependenciesMeta": {
"webpack": {
"@rspack/core": {
"optional": true
}
},
Expand Down
Loading
Loading