Skip to content

Commit

Permalink
feat: add dll & dll-reference plugin examples
Browse files Browse the repository at this point in the history
  • Loading branch information
谢奇璇 committed Nov 13, 2024
1 parent bfae810 commit a73930c
Show file tree
Hide file tree
Showing 11 changed files with 329 additions and 43 deletions.
274 changes: 231 additions & 43 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions rspack/dll-reference/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import a from '../dll/a';
import alpha from '../dll/alpha';
import beta from 'beta/beta'
import b from 'beta/b'
import c from 'beta/c'


console.log(a)
console.log(alpha)
console.log(beta)
console.log(b)
console.log(c)
13 changes: 13 additions & 0 deletions rspack/dll-reference/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "example-dll-reference-plugin",
"private": true,
"scripts": {
"dev": "rspack serve",
"build": "rspack build || echo 'make-ci-happy'"
},
"devDependencies": {
"@rspack/cli": "1.1.1",
"@rspack/core": "1.1.1",
"typescript": "^5.3.3"
}
}
28 changes: 28 additions & 0 deletions rspack/dll-reference/rspack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

const rspack = require('@rspack/core')
const path = require('node:path');

/** @type {import('@rspack/cli').Configuration} */
const config = {
entry: './index',
output: {
path: path.resolve(__dirname, 'dist'),
},
resolve: {
extensions: ['...', '.ts', '.tsx', '.js', '.jsx']
},
plugins: [
new rspack.DllReferencePlugin({
manifest: path.resolve(__dirname, '../dll/dist/alpha.manifest.json'),
extensions: ['.js', '.ts'],
}),
new rspack.DllReferencePlugin({
manifest: path.resolve(__dirname, '../dll/dist/beta.manifest.json'),
scope: 'beta',
extensions: [".js", ".jsx", '.ts', '.tsx']
}),
],
mode: 'development'
}

module.exports = config;
1 change: 1 addition & 0 deletions rspack/dll/a.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default "a";
1 change: 1 addition & 0 deletions rspack/dll/alpha.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default "alpha";
1 change: 1 addition & 0 deletions rspack/dll/b.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default "b";
1 change: 1 addition & 0 deletions rspack/dll/beta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default "beta"
1 change: 1 addition & 0 deletions rspack/dll/c.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default "c.tsx";
13 changes: 13 additions & 0 deletions rspack/dll/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "example-dll-plugin",
"private": true,
"scripts": {
"dev": "rspack serve",
"build": "rspack build || echo 'make-ci-happy'"
},
"devDependencies": {
"@rspack/cli": "1.1.1",
"@rspack/core": "1.1.1",
"typescript": "^5.3.3"
}
}
27 changes: 27 additions & 0 deletions rspack/dll/rspack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

const rspack = require('@rspack/core')
const path = require('node:path');

/** @type {import('@rspack/cli').Configuration} */
const config = {
resolve: {
extensions: ['...', '.ts', '.tsx', '.js', '.jsx'],
},
entry: {
alpha: ["./alpha", "./a"],
beta: ["./beta", "./b", "./c"],
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].dll.js',
library: '[name]_dll_lib'
},
plugins: [
new rspack.DllPlugin({
path: path.join(__dirname, "dist", "[name].manifest.json"),
name: '[name]_dll_lib',
})
]
}

module.exports = config;

0 comments on commit a73930c

Please sign in to comment.