Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.

Commit 3593a55

Browse files
committed
feat(esbuild): added commonjs transformation along with esbuild.
1 parent 243335d commit 3593a55

File tree

3 files changed

+31
-18
lines changed

3 files changed

+31
-18
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ dist/
4242
# Jekyll
4343
demo-site/_site/
4444
demo-site/dist/
45+
46+
.yalc
47+
*yalc.lock

esbuild.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,34 @@
1-
const { build } = require("esbuild");
2-
const { nodeExternalsPlugin } = require("esbuild-node-externals");
1+
const { build } = require('esbuild')
2+
const { nodeExternalsPlugin } = require('esbuild-node-externals')
33

4-
build({
5-
entryPoints: ["src/index.js"],
6-
outdir: "dist",
4+
const configuration = {
5+
outdir: 'dist',
6+
entryPoints: ['src/index.js'],
77
bundle: true,
88
sourcemap: true,
99
minify: true,
10-
splitting: true,
11-
format: "esm",
12-
target: ["es2015"],
10+
target: 'es2015',
1311
loader: {
14-
".js": "jsx",
12+
'.js': 'jsx',
1513
},
1614
plugins: [nodeExternalsPlugin()],
17-
}).catch(() => process.exit(1));
15+
}
16+
17+
async function esbuild() {
18+
// build esm version.
19+
await build({
20+
...configuration,
21+
format: 'esm',
22+
splitting: true,
23+
outExtension: { '.js': '.esm.js' },
24+
outdir: 'dist',
25+
}).catch(() => process.exit(1))
26+
27+
// build cjs version.
28+
await build({
29+
...configuration,
30+
format: 'cjs',
31+
}).catch(() => process.exit(1))
32+
}
33+
34+
esbuild()

package.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
{
22
"name": "react-keyed-file-browser",
3-
"version": "1.12.1",
3+
"version": "1.13.0",
44
"description": "Folder based file browser given a flat keyed list of objects, powered by React.",
55
"main": "dist/index.js",
6-
"module": "dist/index.js",
7-
"exports": {
8-
".": {
9-
"require": "./dist/index.js",
10-
"import": "./dist/index.js"
11-
}
12-
},
136
"scripts": {
147
"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;",
158
"test": "echo \"Error: no test specified\" && exit 1",

0 commit comments

Comments
 (0)