Skip to content

Commit

Permalink
feat(export): fix export issue
Browse files Browse the repository at this point in the history
  • Loading branch information
unadlib committed Feb 25, 2024
1 parent 370e798 commit 137091b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 64 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mutability
# Mutability

![Node CI](https://github.com/unadlib/mutability/workflows/Node%20CI/badge.svg)
[![npm version](https://badge.fury.io/js/mutability.svg)](http://badge.fury.io/js/mutability)
Expand Down Expand Up @@ -60,3 +60,7 @@ test('base - mutate with error', () => {
});
});
```

## License

Mutability is [MIT licensed](https://github.com/unadlib/mutability/blob/main/LICENSE).
7 changes: 0 additions & 7 deletions lib/index.js

This file was deleted.

16 changes: 10 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@
"name": "mutability",
"version": "0.1.1",
"description": "A JavaScript library for transactional mutable updates",
"main": "lib/index.js",
"main": "lib/index.cjs.js",
"unpkg": "dist/index.umd.js",
"types": "dist/index.d.ts",
"umd:main": "dist/index.umd.js",
"module": "dist/index.esm.js",
"jsnext:main": "dist/index.esm.js",
"react-native": "dist/index.esm.js",
"typings": "dist/index.d.ts",
"source": "src/index.ts",
"sideEffects": false,
"files": [
"dist",
"lib",
"src"
"dist"
],
"scripts": {
"test": "jest",
"clean": "rimraf dist",
"build": "yarn clean && tsc --skipLibCheck && yarn build:prod && yarn build:dev",
"build": "yarn clean && tsc --skipLibCheck && yarn build:prod",
"build:prod": "NODE_ENV=production rollup --config --bundleConfigAsCjs",
"build:dev": "NODE_ENV=development rollup --config --bundleConfigAsCjs",
"commit": "yarn git-cz"
},
"repository": {
Expand Down
88 changes: 38 additions & 50 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,43 @@ import replace from '@rollup/plugin-replace';
import { terser } from 'rollup-plugin-terser';
import pkg from './package.json';

const isProduction = process.env.NODE_ENV === 'production';
const input = './dist/index.js';

export default isProduction
? {
input,
output: [
{
format: 'cjs',
exports: 'auto',
file: 'dist/index.cjs.js',
sourcemap: true,
},
{
format: 'umd',
name: pkg.name
.split('-')
.map(([s, ...rest]) => [s.toUpperCase(), ...rest].join(''))
.join(''),
file: pkg.unpkg,
sourcemap: true,
},
],
plugins: [
resolve(),
commonjs(),
replace({
__DEV__: 'false',
preventAssignment: true,
}),
terser(),
],
}
: {
input,
output: [
{
format: 'cjs',
exports: 'auto',
file: 'dist/index.cjs.development.js',
sourcemap: true,
},
],
plugins: [
resolve(),
commonjs(),
replace({
__DEV__: 'true',
preventAssignment: true,
}),
],
};
export default {
input,
output: [
{
format: 'cjs',
exports: 'auto',
file: 'dist/index.cjs.js',
sourcemap: true,
},
{
format: 'es',
file: 'dist/index.esm.js',
sourcemap: true,
},
{
format: 'umd',
name: pkg.name
.split('-')
.map(([s, ...rest]) => [s.toUpperCase(), ...rest].join(''))
.join(''),
file: pkg.unpkg,
sourcemap: true,
globals: {
mutative: 'Mutative',
},
},
],
plugins: [
resolve(),
commonjs(),
replace({
__DEV__: 'false',
preventAssignment: true,
}),
terser(),
],
external: ['mutative'],
};
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ export const mutate = <T>(baseState: T, recipe: (state: T) => void) => {
});
apply(baseState, patches);
};

export default mutate;

0 comments on commit 137091b

Please sign in to comment.