Skip to content

Commit

Permalink
Use a bundler to improve the compilation results
Browse files Browse the repository at this point in the history
  • Loading branch information
synw committed Dec 10, 2022
1 parent 4ddc760 commit d83f695
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.DS_Store
node_modules
lib
dist
yarn.lock
package-lock.json

Expand Down
24 changes: 14 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,31 +1,35 @@
{
"name": "djangoinstant",
"version": "0.4.0",
"version": "0.5.0",
"description": "Client for the django-instant websockets backend",
"scripts": {
"build": "tsc",
"build": "rm -f dist/* && rollup -c",
"test": "echo \"Error: no test specified\" && exit 1"
},
"files": [
"/lib"
"/dist"
],
"main": "./lib/index.js",
"module": "./lib/index.js",
"types": "./lib/index.d.ts",
"main": "./dist/index.js",
"module": "./dist/index.es.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./lib/index.js",
"require": "./lib/index.js"
"import": "./dist/index.es.js",
"require": "./dist/index.cjs.min.js"
}
},
"dependencies": {
"centrifuge": "^3.0.1"
},
"devDependencies": {
"tslib": "^2.1.0",
"typescript": "^4.2.3"
"typescript": "^4.2.3",
"rollup": "^2.70.0",
"rollup-plugin-terser": "^7.0.2",
"@rollup/plugin-commonjs": "^21.0.2",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-typescript": "^8.3.1"
},
"prepublish": "tsc",
"author": "synw",
"license": "MIT",
"repository": {
Expand Down
36 changes: 36 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import resolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import { terser } from 'rollup-plugin-terser';

//const isProduction = !process.env.ROLLUP_WATCH;

export default {
input: 'src/index.ts',
output: [
{
file: 'dist/index.cjs.min.js',
format: 'cjs',
plugins: [terser(),]
},
{
file: 'dist/index.es.js',
format: 'esm'
},
{
file: 'dist/index.min.js',
format: 'iife',
name: '$instant',
plugins: [terser()]
}],
plugins: [
typescript(),
resolve({
jsnext: true,
main: true,
browser: true,
}),
commonjs(),
//isProduction && terser({ format: { comments: false } }),
],
};

0 comments on commit d83f695

Please sign in to comment.