https://github.com/LonelySnowman/rspack-deno-plugin
Make rspack run correctly in the deno environment.
https://github.com/LonelySnowman/rspack-deno-plugin
Last synced: about 1 month ago
JSON representation
Make rspack run correctly in the deno environment.
- Host: GitHub
- URL: https://github.com/LonelySnowman/rspack-deno-plugin
- Owner: LonelySnowman
- License: mit
- Created: 2025-01-31T11:24:58.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-02-09T17:02:30.000Z (10 months ago)
- Last Synced: 2025-02-09T17:34:50.060Z (10 months ago)
- Language: TypeScript
- Size: 97.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-rstack - rspack-deno-plugin
README
# rspack-deno-plugin
Deno module resolution for rspack and rsbuild.
- Support for `http:`, `https:`, `jsr:`, and `npm:` specifiers.
- Support deno workspace running.
> This project learns [esbuild_deno_loader](https://github.com/lucacasonato/esbuild_deno_loader)
## How to use
- You need to set `"nodeModulesDir": "auto"` in deno.json before start.
- [npm](https://www.npmjs.com/package/rspack-deno-plugin) | [jsr](https://jsr.io/@snowman/rspack-deno-plugin)
### NPM Package
```bash
# install package
deno install npm:rspack-deno-plugin
```
- Use in `rsbuild.config.ts`
```ts
import { defineConfig } from '@rsbuild/core';
import RspackDenoPlugin from 'rspack-deno-plugin';
export default defineConfig({
// ...
tools: {
rspack: {
plugins: [new RspackDenoPlugin()],
},
},
});
```
- Use in `rspack.config.ts`
```bash
# Install ts parser before running
deno install npm:esbuild npm:esbuild-register
```
```ts
import { defineConfig } from '@rspack/cli';
import RspackDenoPlugin from 'rspack-deno-plugin';
export default defineConfig({
// ...
plugins: [new RspackDenoPlugin()],
});
```
### JSR Package
- Can only be run with `rsbuild` api.
```bash
# install package
deno install jsr:@snowman/rspack-deno-plugin
```
```ts
// create rsbuild script file like rsbuild-script.ts
import { createRsbuild } from '@rsbuild/core';
import RspackDenoPlugin from '@snowman/rspack-deno-plugin';
const rsbuild = await createRsbuild({
rsbuildConfig: {
tools: {
rspack: {
// add rspack plugin
plugins: [new RspackDenoPlugin()],
},
},
},
});
// build
await rsbuild.build();
// preview
await rsbuild.preview();
// dev
await rsbuild.startDevServer();
```
```bash
# run rsbuild script
deno --allow-all ./rsbuild-script.ts
```
## How it works
- `npm:` specifier: Resolve node_modules like node.
- `http:`, `https:`, `jsr:` specifiers: Use `deno info` command to resolve deno local cache.
- `file:`, `data:` specifiers: Resolve by rspack.
## Coming soon
- [ ] Support { "nodeModulesDir": "none" } config in deno.json.