Skip to content

Commit

Permalink
feat: support resolveId for rspack (#388)
Browse files Browse the repository at this point in the history
* feat: support resolveId for rspack

* fix

* use resolve hook

* use alpha version

* remove skip rspack

* lint code

* Update src/rspack/utils.ts

Co-authored-by: Kevin Deng 三咲智子 <[email protected]>

* Update docs/guide/index.md

Co-authored-by: Kevin Deng 三咲智子 <[email protected]>

---------

Co-authored-by: Kevin Deng 三咲智子 <[email protected]>
  • Loading branch information
ahabhgk and sxzz committed Jul 23, 2024
1 parent 8326732 commit 7e4cecb
Show file tree
Hide file tree
Showing 19 changed files with 397 additions and 205 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,3 @@ jobs:
if: ${{ matrix.node == 16 }}
env:
IS_WEBPACK_4: 'true'
SKIP_RSPACK: 'true'
11 changes: 6 additions & 5 deletions docs/guide/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,12 @@ export default defineConfig({
| ----------------------------------------------------------------------------------| :-------------: | :--: | :-------: | :-------: | :-----------: | :----: | :---: |
| [`enforce`](https://vitejs.dev/guide/api-plugin.html#plugin-ordering) | ❌ <sup>1</sup> |||| ❌ <sup>1</sup> |||
| [`buildStart`](https://rollupjs.org/plugin-development/#buildstart) ||||||||
| [`resolveId`](https://rollupjs.org/plugin-development/#resolveid) |||||| ||
| [`resolveId`](https://rollupjs.org/plugin-development/#resolveid) |||||| ✅ <sup>5</sup> ||
| `loadInclude`<sup>2</sup> ||||||||
| [`load`](https://rollupjs.org/plugin-development/#load) ||||| ✅ <sup>3</sup> |||
| `transformInclude`<sup>2</sup> ||||||||
| [`transform`](https://rollupjs.org/plugin-development/#transform) ||||| ✅ <sup>3</sup> |||
| [`watchChange`](https://rollupjs.org/plugin-development/#watchchange) |||||| ||
| [`watchChange`](https://rollupjs.org/plugin-development/#watchchange) |||||| ||
| [`buildEnd`](https://rollupjs.org/plugin-development/#buildend) ||||||||
| [`writeBundle`](https://rollupjs.org/plugin-development/#writebundle)<sup>4</sup> ||||||||

Expand All @@ -186,6 +186,7 @@ export default defineConfig({
2. webpack's id filter is outside of loader logic; an additional hook is needed for better perf on webpack. In Rollup and Vite, this hook has been polyfilled to match the behaviors. See for the following usage examples.
3. Although esbuild can handle both JavaScript and CSS and many other file formats, you can only return JavaScript in `load` and `transform` results.
4. Currently, `writeBundle` is only serves as a hook for the timing. It doesn't pass any arguments.
5. Rspack supports `resolveId` with a minimum required version of v1.0.0-alpha.1.
:::

### Usage
Expand Down Expand Up @@ -229,9 +230,9 @@ export const farmPlugin = unplugin.farm
| Context | Rollup | Vite | webpack 4 | webpack 5 | esbuild | Rspack | Farm |
| -------------------------------------------------------------------------- | :----: | :--: | :-------: | :-------: | :-----: | :----: | :---: |
| [`this.parse`](https://rollupjs.org/plugin-development/#this-parse) ||||||||
| [`this.addWatchFile`](https://rollupjs.org/plugin-development/#this-addwatchfile) |||||| ||
| [`this.addWatchFile`](https://rollupjs.org/plugin-development/#this-addwatchfile) |||||| ||
| [`this.emitFile`](https://rollupjs.org/plugin-development/#this-emitfile)<sup>1</sup> ||||||||
| [`this.getWatchFiles`](https://rollupjs.org/plugin-development/#this-getwatchfiles) |||||| ||
| [`this.getWatchFiles`](https://rollupjs.org/plugin-development/#this-getwatchfiles) |||||| ||
| [`this.warn`](https://rollupjs.org/plugin-development/#this-warn) ||||||||
| [`this.error`](https://rollupjs.org/plugin-development/#this-error) ||||||||

Expand Down Expand Up @@ -320,7 +321,7 @@ export const unpluginFactory: UnpluginFactory<Options | undefined> = (options, m
// Configure webpack compiler
},
rspack(compiler) {
// Configure webpack compiler
// Configure Rspack compiler
},
esbuild: {
// Change the filter of onResolve and onLoad
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,15 @@
"@farmfe/cli": "^1.0.0",
"@farmfe/core": "^1.0.19",
"@rolldown/node": "^0.0.5",
"@rspack/cli": "^0.6.1",
"@rspack/core": "^0.6.1",
"@rspack/cli": "1.0.0-alpha.2",
"@rspack/core": "1.0.0-alpha.2",
"@types/fs-extra": "^11.0.4",
"@types/node": "^20.12.7",
"@types/webpack-sources": "^3.2.3",
"bumpp": "^9.4.0",
"conventional-changelog-cli": "^4.1.0",
"esbuild": "^0.20.2",
"esbuild-plugin-copy": "^2.1.1",
"eslint": "^8.57.0",
"fast-glob": "^3.3.2",
"fs-extra": "^11.2.0",
Expand Down
Loading

0 comments on commit 7e4cecb

Please sign in to comment.