mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-13 14:30:02 -04:00
setup rspack
Co-authored-by: Percs <Percslol@users.noreply.github.com>
This commit is contained in:
parent
b448c5505b
commit
146c202ae2
5 changed files with 2847 additions and 144 deletions
11
package.json
11
package.json
|
@ -9,9 +9,8 @@
|
||||||
"url": "https://github.com/MercuryWorkshop/scramjet"
|
"url": "https://github.com/MercuryWorkshop/scramjet"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup -c",
|
"build": "rspack build",
|
||||||
"dev": "node server.js",
|
"dev": "node server.js",
|
||||||
"temp": "rollup -c -w",
|
|
||||||
"prepublish": "pnpm build",
|
"prepublish": "pnpm build",
|
||||||
"pub": "pnpm publish --no-git-checks --access public"
|
"pub": "pnpm publish --no-git-checks --access public"
|
||||||
},
|
},
|
||||||
|
@ -27,9 +26,9 @@
|
||||||
"@mercuryworkshop/bare-as-module3": "^2.2.2",
|
"@mercuryworkshop/bare-as-module3": "^2.2.2",
|
||||||
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
"@mercuryworkshop/epoxy-transport": "^2.1.3",
|
||||||
"@mercuryworkshop/libcurl-transport": "^1.3.6",
|
"@mercuryworkshop/libcurl-transport": "^1.3.6",
|
||||||
"@rollup/plugin-inject": "^5.0.5",
|
"@rsdoctor/rspack-plugin": "^0.3.7",
|
||||||
"@rollup/plugin-replace": "^5.0.5",
|
"@rspack/cli": "^0.7.5",
|
||||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
"@rspack/core": "^0.7.5",
|
||||||
"@tomphttp/bare-server-node": "^2.0.3",
|
"@tomphttp/bare-server-node": "^2.0.3",
|
||||||
"@types/eslint": "^8.56.10",
|
"@types/eslint": "^8.56.10",
|
||||||
"@types/estree": "^1.0.5",
|
"@types/estree": "^1.0.5",
|
||||||
|
@ -40,8 +39,6 @@
|
||||||
"dotenv": "^16.4.5",
|
"dotenv": "^16.4.5",
|
||||||
"eslint": "^8.57.0",
|
"eslint": "^8.57.0",
|
||||||
"fastify": "^4.26.2",
|
"fastify": "^4.26.2",
|
||||||
"rollup": "^4.17.2",
|
|
||||||
"rollup-plugin-typescript2": "^0.36.0",
|
|
||||||
"tslib": "^2.6.2",
|
"tslib": "^2.6.2",
|
||||||
"typescript": "^5.4.5"
|
"typescript": "^5.4.5"
|
||||||
},
|
},
|
||||||
|
|
2895
pnpm-lock.yaml
generated
2895
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -1,34 +0,0 @@
|
||||||
import typescript from "rollup-plugin-typescript2";
|
|
||||||
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
||||||
import { join } from "node:path";
|
|
||||||
import fs from "node:fs"
|
|
||||||
import { fileURLToPath } from "node:url";
|
|
||||||
|
|
||||||
// check if its
|
|
||||||
const production = !process.env.ROLLUP_WATCH;
|
|
||||||
console.log(production)
|
|
||||||
fs.rmSync(join(fileURLToPath(new URL(".", import.meta.url)), "./dist"), { recursive: true, force: true })
|
|
||||||
|
|
||||||
const commonPlugins = () => [
|
|
||||||
typescript(),
|
|
||||||
nodeResolve(),
|
|
||||||
]
|
|
||||||
|
|
||||||
export default {
|
|
||||||
plugins: commonPlugins(),
|
|
||||||
treeshake: "recommended",
|
|
||||||
input: {
|
|
||||||
client: "./src/client/index.ts",
|
|
||||||
shared: "./src/shared/index.ts",
|
|
||||||
worker: "./src/worker/index.ts",
|
|
||||||
codecs: "./src/codecs/index.ts",
|
|
||||||
config: "./src/scramjet.config.ts"
|
|
||||||
},
|
|
||||||
output: {
|
|
||||||
entryFileNames: "scramjet.[name].js",
|
|
||||||
dir: "./dist",
|
|
||||||
// format: "amd",
|
|
||||||
sourcemap: true,
|
|
||||||
compact: production
|
|
||||||
}
|
|
||||||
};
|
|
49
rspack.config.js
Normal file
49
rspack.config.js
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import { defineConfig } from "@rspack/cli";
|
||||||
|
// import { RsdoctorRspackPlugin } from "@rsdoctor/rspack-plugin";
|
||||||
|
import { join } from "path";
|
||||||
|
import { fileURLToPath } from "url";
|
||||||
|
|
||||||
|
const __dirname = fileURLToPath(new URL(".", import.meta.url));
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
entry: {
|
||||||
|
shared: join(__dirname, "src/shared/index.ts"),
|
||||||
|
worker: join(__dirname, "src/worker/index.ts"),
|
||||||
|
client: join(__dirname, "src/client/index.ts"),
|
||||||
|
config: join(__dirname, "src/scramjet.config.ts"),
|
||||||
|
codecs: join(__dirname, "src/codecs/index.ts"),
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
extensions: [".ts", ".js"],
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.ts$/,
|
||||||
|
use: "builtin:swc-loader",
|
||||||
|
exclude: ["/node_modules/"],
|
||||||
|
options: {
|
||||||
|
jsc: {
|
||||||
|
parser: {
|
||||||
|
syntax: "typescript"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
type: "javascript/auto"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
filename: "scramjet.[name].js",
|
||||||
|
path: join(__dirname, "dist")
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// new RsdoctorRspackPlugin({
|
||||||
|
// supports: {
|
||||||
|
// parseBundle: true,
|
||||||
|
// banner: true
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
],
|
||||||
|
watch: true
|
||||||
|
});
|
|
@ -69,7 +69,7 @@ fastify.listen({
|
||||||
port: process.env.PORT || 1337
|
port: process.env.PORT || 1337
|
||||||
});
|
});
|
||||||
|
|
||||||
const watch = spawn("pnpm", ["rollup", "-c", "-w"], { detached: true, cwd: process.cwd() });
|
const watch = spawn("pnpm", ["rspack", "-w"], { detached: true, cwd: process.cwd() });
|
||||||
|
|
||||||
watch.stdout.on("data", (data) => {
|
watch.stdout.on("data", (data) => {
|
||||||
console.log(`${data}`);
|
console.log(`${data}`);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue