diff --git a/package.json b/package.json index 85ce1b7..c1bc720 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,21 @@ { "name": "interval-bins", - "version": "1.0.1", + "version": "1.0.2", "repository": { "type": "git", "url": "git+https://github.com/plantinformatics/interval-bins.git" }, "description": "binEvenLengthRound() : Calculate the bin size for even-sized bins to span the given interval. binBoundaries() : Generate an array of even-sized bins to span the given interval.", - "main": "src/index.js", + "type": "module", + "main": "main.js", "browser": "dist/interval-bins.js", "exports": { - "import": "./dist/interval-bins.js", - "require": "./src/index.js" + ".": { + "import": "./dist/interval-bins.mjs", + "require": "./dist/interval-bins.cjs" + }, + "./dist/interval-bins.mjs": "./dist/interval-bins.mjs", + "./dist/interval-bins.cjs": "./dist/interval-bins.cjs" }, "files": [ "dist", @@ -18,8 +23,7 @@ ], "scripts": { "test": "echo \"Error: no test specified\" && exit 1", - "prepare": "rm -rf build && mkdir build && rollup -f umd -n interval-bins -o dist/interval-bins.js -- main.js", - "build": "webpack" + "prepare": "rm -rf dist && mkdir dist && rollup -c" }, "keywords": [ "javascript", diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..ae827a4 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,26 @@ +import resolve from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; +import json from '@rollup/plugin-json'; + +export default { + input: 'main.js', // Entry point for the application + output: [ + { + file: 'dist/interval-bins.mjs', // Output bundle location + format: 'esm' + }, + { + file: 'dist/interval-bins.cjs', // Output bundle location + format: 'cjs' // CommonJS format suitable for Node.js require() + } + ], + plugins: [ + resolve({ + preferBuiltins: true // Prefer Node.js built-ins over npm modules if available + }), + commonjs(), + json() + ], + // List of Node built-in modules to leave as external dependencies + // external: [] +}; diff --git a/webpack.config.js b/webpack.config.js deleted file mode 100644 index 1a7703c..0000000 --- a/webpack.config.js +++ /dev/null @@ -1,22 +0,0 @@ -//------------------------------------------------------------------------------ -/* global require */ -/* global module */ -/* global __dirname */ -//------------------------------------------------------------------------------ - -const path = require('path'); - -module.exports = { - mode : 'production', - output: { - path: path.resolve(__dirname, 'dist'), - filename: 'interval-bins.js', - - globalObject: 'this', - - library: { - name: 'interval-bins', - type: 'umd', - }, - }, -};