Skip to content

Commit a3b4606

Browse files
committed
Don't rollup cjs/mjs files only websocket for browser
1 parent 12481a2 commit a3b4606

6 files changed

Lines changed: 21 additions & 28 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
dist/
22
docs/
3+
lib/
4+
types/
35
examples/
46
node_modules/
57
coverage/

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,30 @@
33
"version": "1.3.2",
44
"description": "AMQP 0-9-1 client, both for browsers (WebSocket) and node (TCP Socket)",
55
"type": "module",
6-
"main": "dist/amqp-client.cjs",
7-
"types": "dist/types/amqp-client.d.ts",
6+
"main": "lib/cjs/amqp-client.js",
7+
"types": "types/index.d.ts",
88
"browser": "dist/amqp-websocket-client.mjs",
99
"exports": {
10-
"import": "./dist/amqp-client.mjs",
11-
"require": "./dist/amqp-client.cjs"
10+
"import": "./lib/mjs/amqp-client.js",
11+
"require": "./lib/cjs/amqp-client.js"
1212
},
1313
"engines": {
1414
"node": ">=12.0.0"
1515
},
1616
"scripts": {
17-
"docs": "typedoc --entryPoints src/amqp-client.ts",
17+
"docs": "typedoc src/index.ts",
1818
"lint": "eslint src",
1919
"test": "c8 ava",
2020
"prebuild": "sed -i'' \"s/VERSION = .*/VERSION = '$npm_package_version'/\" src/amqp-base-client.ts && git add src/amqp-base-client.ts",
21-
"build": "rm -rf dist && rollup -c && tsc --emitDeclarationOnly --module commonjs",
21+
"build": "tsc && tsc --outDir lib/cjs/ --module commonjs && rollup -c",
2222
"prepack": "npm run build",
2323
"preversion": "npm test",
2424
"version": "npm run build"
2525
},
2626
"files": [
2727
"src/",
28+
"lib/",
29+
"types/",
2830
"dist/"
2931
],
3032
"repository": "github:cloudamqp/amqp-client.js",

rollup.config.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import typescript from '@rollup/plugin-typescript'
22

33
const options = {
4-
exclude: ["src/amqp-client.ts"], // includes a ts hack for default export in commonjs module
54
removeComments: true, // comments only required in declarations
65
declaration: false, // let tsc generate declarations
76
declarationMap: false,
@@ -15,22 +14,5 @@ export default [
1514
file: 'dist/amqp-websocket-client.mjs',
1615
sourcemap: 'dist/amqp-websocket-client.mjs.map'
1716
}
18-
}, {
19-
input: 'src/amqp-socket-client.ts',
20-
external: ['buffer', 'net', 'tls'],
21-
plugins: [typescript(options)],
22-
output: {
23-
file: 'dist/amqp-client.cjs',
24-
format: 'cjs',
25-
sourcemap: 'dist/amqp-client.cjs.map'
26-
}
27-
}, {
28-
input: 'src/amqp-socket-client.ts',
29-
external: ['buffer', 'net', 'tls'],
30-
plugins: [typescript(options)],
31-
output: {
32-
file: 'dist/amqp-client.mjs',
33-
sourcemap: 'dist/amqp-client.mjs.map'
34-
}
3517
}
3618
]

src/amqp-client.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export { AMQPClient } from './amqp-socket-client.js'
2-
export { AMQPWebSocketClient } from './amqp-websocket-client.js'
32
export { AMQPChannel } from './amqp-channel.js'
43
export { AMQPQueue } from './amqp-queue.js'
54
export { AMQPConsumer } from './amqp-consumer.js'

src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export { AMQPClient } from './amqp-socket-client.js'
2+
export { AMQPWebSocketClient } from './amqp-websocket-client.js'
3+
export { AMQPChannel } from './amqp-channel.js'
4+
export { AMQPQueue } from './amqp-queue.js'
5+
export { AMQPConsumer } from './amqp-consumer.js'
6+
export { AMQPError } from './amqp-error.js'
7+
export { AMQPMessage } from './amqp-message.js'
8+
export { AMQPProperties, Field } from './amqp-properties.js'

tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
88
"declarationMap": true, /* Create sourcemaps for d.ts files. */
99
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
10-
"outDir": "dist", /* Specify an output folder for all emitted files. */
11-
"declarationDir": "dist/types", /* Specify the output directory for generated declaration files. */
10+
"outDir": "lib/mjs", /* Specify an output folder for all emitted files. */
11+
"declarationDir": "types", /* Specify the output directory for generated declaration files. */
1212
"removeComments": false, /* Disable emitting comments. */
1313
"noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
14-
"esModuleInterop": false, /* Emit additional JavaScript to ease support for importing CommonJS modules.*/
14+
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules.*/
1515
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
1616
"strict": true, /* Enable all strict type-checking options. */
1717
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */

0 commit comments

Comments
 (0)