Skip to content

Commit

Permalink
feat(esbuild): added commonjs transformation along with esbuild.
Browse files Browse the repository at this point in the history
  • Loading branch information
dreadera committed Jul 20, 2021
1 parent 243335d commit 3593a55
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ dist/
# Jekyll
demo-site/_site/
demo-site/dist/

.yalc
*yalc.lock
37 changes: 27 additions & 10 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
const { build } = require("esbuild");
const { nodeExternalsPlugin } = require("esbuild-node-externals");
const { build } = require('esbuild')
const { nodeExternalsPlugin } = require('esbuild-node-externals')

build({
entryPoints: ["src/index.js"],
outdir: "dist",
const configuration = {
outdir: 'dist',
entryPoints: ['src/index.js'],
bundle: true,
sourcemap: true,
minify: true,
splitting: true,
format: "esm",
target: ["es2015"],
target: 'es2015',
loader: {
".js": "jsx",
'.js': 'jsx',
},
plugins: [nodeExternalsPlugin()],
}).catch(() => process.exit(1));
}

async function esbuild() {
// build esm version.
await build({
...configuration,
format: 'esm',
splitting: true,
outExtension: { '.js': '.esm.js' },
outdir: 'dist',
}).catch(() => process.exit(1))

// build cjs version.
await build({
...configuration,
format: 'cjs',
}).catch(() => process.exit(1))
}

esbuild()
9 changes: 1 addition & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
{
"name": "react-keyed-file-browser",
"version": "1.12.1",
"version": "1.13.0",
"description": "Folder based file browser given a flat keyed list of objects, powered by React.",
"main": "dist/index.js",
"module": "dist/index.js",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.js"
}
},
"scripts": {
"publish-demo": "git branch -D gh-pages; git push origin --delete gh-pages; git checkout -b gh-pages; cd demo-site; yarn; npm run build; cd ..; git add .; git add -f demo-site/dist; git add -f demo-site/node_modules/uptick-demo-site/dist; git commit -m \"Demo site build\"; git push origin gh-pages; git checkout master; git push origin `git subtree split --prefix demo-site gh-pages`:gh-pages --force;",
"test": "echo \"Error: no test specified\" && exit 1",
Expand Down

0 comments on commit 3593a55

Please sign in to comment.