Skip to content

Commit

Permalink
Update typescript and rollup build to produce types and add exports t…
Browse files Browse the repository at this point in the history
…o package.json
  • Loading branch information
tylerbutler committed Oct 23, 2024
1 parent e4f1c46 commit 66616bf
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 9 deletions.
24 changes: 24 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@
"description": "Visualization of JSSM machines using viz.js",
"main": "dist/jssm-viz.cjs.cjs",
"module": "dist/jssm-viz.es6.js",
"exports": {
"require": {
"types": "./dist/jssm-viz.d.cts",
"default": "./dist/jssm-viz.cjs.cjs"
},
"import": {
"types": "./dist/jssm-viz.es6.d.ts",
"default": "./dist/jssm-viz.es6.js"
},
"browser": "./dist/jssm-viz.iife.js"
},
"scripts": {
"test": "jest --verbose",
"clean": "rimraf build -f && rimraf dist -f && rimraf docs -f && mkdir build && cd build && mkdir terser && cd .. && mkdir dist && mkdir docs && cd docs && mkdir docs && cd ../src/ts && rimraf -f generated_code && mkdir generated_code && cd ../..",
Expand Down Expand Up @@ -74,6 +85,7 @@
"pegjs": "^0.10.0",
"rimraf": "^2.7.1",
"rollup": "^4.22.4",
"rollup-plugin-dts": "^6.1.1",
"typescript": "^5.5.3",
"uglify-js": "^3.6.2",
"viz.js": "^2.1.2"
Expand Down
42 changes: 34 additions & 8 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

import nodeResolve from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import dts from "rollup-plugin-dts";





const es6config = {
const es6config = [{

input : 'build/typescript/jssm-viz.js',

Expand Down Expand Up @@ -35,13 +35,26 @@ const es6config = {

]

};
}, {

input: 'build/typescript/jssm-viz.d.ts',

output: {
file : './build/rollup/jssm-viz.es6.d.ts',
format : 'es'
},

plugins : [

dts()
]}
];





const cjsconfig = {
const cjsconfig = [{

input : 'build/typescript/jssm-viz.js',

Expand Down Expand Up @@ -70,13 +83,26 @@ const cjsconfig = {

]

};
}, {

input: 'build/typescript/jssm-viz.d.ts',

output: {
file : './build/rollup/jssm-viz.cjs.d.cts',
format : 'cjs'
},

plugins : [

dts()
]}
];





const iifeconfig = {
const iifeconfig = [{

input : 'build/typescript/jssm-viz.js',

Expand Down Expand Up @@ -105,10 +131,10 @@ const iifeconfig = {

]

};
}];





export default [ es6config, cjsconfig, iifeconfig ];
export default [ ...es6config, ...cjsconfig, ...iifeconfig ];
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */

/* Emit */
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
"sourceMap": true, /* Create source map files for emitted JavaScript files. */
Expand Down

0 comments on commit 66616bf

Please sign in to comment.