mirror of
https://github.com/discourse/discourse.git
synced 2024-12-22 23:03:58 +08:00
80b9c280ba
This will bring significant improvements to install speed & storage requirements. For information on how it may affect you, see https://meta.discourse.org/t/324521 This commit: - removes the `yarn.lock` and replaces with `pnpm-lock.yaml` - updates workspaces to pnpm format - adjusts package dependencies to work with pnpm's stricter resolution strategy - updates Rails app to load modules from more specific node_modules directories - adds a `.pnpmfile` which automatically cleans up old yarn-managed `node_modules` directories - updates various scripts to call `pnpm` instead of `yarn` - updates patches to use pnpm's native patch system instead of patch-package - adds a patch for licensee to support pnpm
62 lines
1.4 KiB
JavaScript
62 lines
1.4 KiB
JavaScript
// See: https://esbuild.github.io/plugins/#webassembly-plugin
|
|
|
|
const esbuild = require("esbuild");
|
|
const path = require("node:path");
|
|
const fs = require("node:fs");
|
|
|
|
let wasmPlugin = {
|
|
name: "wasm",
|
|
|
|
setup(build) {
|
|
build.onResolve({ filter: /\.wasm$/ }, (args) => {
|
|
if (args.namespace === "wasm-stub") {
|
|
return {
|
|
path: args.path,
|
|
namespace: "wasm-binary",
|
|
};
|
|
}
|
|
|
|
if (args.resolveDir === "") {
|
|
return;
|
|
}
|
|
|
|
return {
|
|
path: path.isAbsolute(args.path)
|
|
? args.path
|
|
: path.join(args.resolveDir, args.path),
|
|
namespace: "wasm-stub",
|
|
};
|
|
});
|
|
|
|
build.onLoad({ filter: /.*/, namespace: "wasm-stub" }, async (args) => {
|
|
return {
|
|
contents: `export { default } from ${JSON.stringify(args.path)};`,
|
|
};
|
|
});
|
|
|
|
build.onLoad({ filter: /.*/, namespace: "wasm-binary" }, async (args) => {
|
|
return {
|
|
contents: await fs.promises.readFile(args.path),
|
|
loader: "binary",
|
|
};
|
|
});
|
|
},
|
|
};
|
|
|
|
esbuild
|
|
.build({
|
|
logLevel: "warning",
|
|
bundle: true,
|
|
minify: true,
|
|
alias: {
|
|
util: "./node_modules/@zxing/text-encoding",
|
|
},
|
|
define: {
|
|
process: `{ "env": { "EMBER_ENV": "production" } }`,
|
|
},
|
|
external: ["fs", "path"],
|
|
entryPoints: ["./transpiler.js"],
|
|
plugins: [wasmPlugin],
|
|
})
|
|
.then(() => {});
|