Skip to content

Instantly share code, notes, and snippets.

@evanw
Last active September 14, 2021 11:49
Show Gist options
  • Save evanw/a8d65017c7876e85861245af7821d038 to your computer and use it in GitHub Desktop.
Save evanw/a8d65017c7876e85861245af7821d038 to your computer and use it in GitHub Desktop.
{
"presets": [
["env", {
"targets": {
"browsers": ["chrome 85"]
}
}]
]
}
// node: function
// browserify: function
// esbuild: object
// webpack: object
// parcel: object
// rollup: object
console.log(typeof require('node-fetch'));
default: node browserify esbuild webpack parcel rollup
node:
node entry.js
browserify:
npx browserify entry.js -o out-browserify.js && node out-browserify.js
esbuild:
npx esbuild --bundle entry.js --platform=node | node
webpack:
npx webpack entry.js -o out-webpack.js --silent && node out-webpack.js
parcel:
npx parcel build entry.js --out-dir . -o out-parcel.js --no-autoinstall > /dev/null && node out-parcel.js
rollup:
npx rollup -c rollup.config.js entry.js -o out-rollup.js --silent && node out-rollup.js
{
"dependencies": {
"@rollup/plugin-commonjs": "15.0.0",
"@rollup/plugin-node-resolve": "9.0.0",
"browserify": "16.5.2",
"esbuild": "0.6.30",
"node-fetch": "3.0.0-beta.8",
"parcel": "1.12.4",
"rollup": "2.26.10",
"webpack": "4.44.1",
"webpack-cli": "3.3.12"
},
"devDependencies": {
"babel-core": "6.26.3",
"babel-preset-env": "1.7.0"
}
}
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
export default {
output: {
exports: 'auto',
format: 'cjs',
},
plugins: [nodeResolve({
preferBuiltins: true,
}), commonjs()],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment