mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
build: tsup for better cjs / esm support
This commit is contained in:
@@ -177,7 +177,7 @@ test('spawn, connect, send a message, session info, and destroy', async () => {
|
||||
|
||||
await manager.connect();
|
||||
expect(mockConstructor).toHaveBeenCalledWith(
|
||||
expect.stringContaining('worker.cjs'),
|
||||
expect.stringContaining('worker.js'),
|
||||
expect.objectContaining({ workerData: expect.objectContaining({ shardIds: [0, 1] }) }),
|
||||
);
|
||||
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
import { createUnbuildConfig } from '../../build.config';
|
||||
|
||||
export default createUnbuildConfig({
|
||||
entries: [
|
||||
{ builder: 'rollup', input: 'src/index' },
|
||||
{ builder: 'rollup', input: 'src/strategies/sharding/worker' },
|
||||
],
|
||||
externals: ['zlib-sync'],
|
||||
});
|
||||
@@ -4,7 +4,7 @@
|
||||
"description": "Wrapper around Discord's gateway",
|
||||
"scripts": {
|
||||
"test": "vitest run",
|
||||
"build": "unbuild",
|
||||
"build": "tsup",
|
||||
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
||||
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
||||
"docs": "downlevel-dts dist docs/dist --to=3.7 && docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript && api-extractor run --local",
|
||||
@@ -12,12 +12,12 @@
|
||||
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/ws/*'",
|
||||
"release": "cliff-jumper"
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.mjs",
|
||||
"typings": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs",
|
||||
"require": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts"
|
||||
},
|
||||
"directories": {
|
||||
@@ -72,9 +72,8 @@
|
||||
"eslint-config-neon": "^0.1.23",
|
||||
"mock-socket": "^9.1.5",
|
||||
"prettier": "^2.7.1",
|
||||
"rollup-plugin-typescript2": "^0.33.0",
|
||||
"tsup": "^6.2.3",
|
||||
"typescript": "^4.8.2",
|
||||
"unbuild": "^0.8.9",
|
||||
"undici": "^5.10.0",
|
||||
"vitest": "^0.22.1",
|
||||
"zlib-sync": "^0.1.7"
|
||||
|
||||
@@ -92,7 +92,7 @@ export class WorkerShardingStrategy implements IShardingStrategy {
|
||||
shardIds: slice,
|
||||
};
|
||||
|
||||
const worker = new Worker(join(__dirname, 'worker.cjs'), { workerData });
|
||||
const worker = new Worker(join(__dirname, 'worker.js'), { workerData });
|
||||
await once(worker, 'online');
|
||||
worker
|
||||
.on('error', (err) => {
|
||||
|
||||
9
packages/ws/tsup.config.js
Normal file
9
packages/ws/tsup.config.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { createTsupConfig } from '../../tsup.config.js';
|
||||
|
||||
export default createTsupConfig({
|
||||
entry: {
|
||||
index: 'src/index.ts',
|
||||
worker: 'src/strategies/sharding/worker.ts',
|
||||
},
|
||||
external: ['zlib-sync'],
|
||||
});
|
||||
Reference in New Issue
Block a user