Skip to content

Commit

Permalink
add cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronny Krammer committed Jan 30, 2022
1 parent 4807071 commit dc18b8c
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 8 deletions.
23 changes: 17 additions & 6 deletions esbuild.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ const typeDefinitionFiles = glob.sync('./src/**/*+(.d.ts)');
const excludeFiles = [...documentationFiles, ...typeDefinitionFiles];
const entryPoints = allSrcFiles.filter(item => !excludeFiles.includes(item));

const options = {
const commonOptions = {
entryPoints: ['./src/index.ts'],
bundle: true,
format: 'esm',
outdir: './dist',
outbase: './src',
logLevel: 'info',
minify: true,
sourcemap: true,
splitting: true,
target: ['esnext'],
platform: 'node',
loader: { '.png': 'dataurl' },
plugins: [
Expand Down Expand Up @@ -57,4 +53,19 @@ const options = {
]
};

build(options).catch((e) => { process.exit(1); });
const cjsOptions = {
...commonOptions,
format: 'cjs',
target: ['node16.0'],
outdir: './dist',
};

const esmOptions = {
...commonOptions,
format: 'esm',
target: ['esnext'],
outfile: './dist/index.esm.js',
};

build(cjsOptions).catch((e) => { process.exit(1); });
build(esmOptions).catch((e) => { process.exit(1); });
90 changes: 90 additions & 0 deletions package-lock.json

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

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"description": "React UI component library built with Tailwind CSS",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"version": "0.1.14",
"version": "0.1.15",
"license": "Apache-2.0",
"author": "Ronny Krammer",
"repository": {
"type": "git",
"url": "https://github.com/salzpate/react-ui.git"
},
"module": "dist/index.js",
"module": "dist/index.esm.js",
"files": [
"dist",
"src"
Expand Down Expand Up @@ -100,6 +100,8 @@
"stylelint-order": "^5.0.0",
"stylelint-prettier": "^2.0.0",
"tailwindcss": "^3.0.18",
"temp": "^0.9.4",
"tmp": "^0.2.1",
"tslib": "^2.3.1",
"typescript": "^4.5.5"
}
Expand Down

0 comments on commit dc18b8c

Please sign in to comment.