Skip to content

Commit

Permalink
build: add umd build
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeysova committed May 31, 2021
1 parent 6714233 commit cded257
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .config/eslint-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"**/*.spec.tsx",
"**/*.spec.ts",
"**/*.spec.js",
"_/**.js"
"_/**.js",
"rollup.config.js"
],
"env": { "jest": true },
"rules": {
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ typings/
# nuxt.js build output
.nuxt

# rollup.js default build output
# rollup.config.js default build output
dist/

# Uncomment the public line if your project uses Gatsby
Expand Down Expand Up @@ -179,6 +179,5 @@ $RECYCLE.BIN/

# End of https://www.gitignore.io/api/node,windows,linux,macos

patronum.cjs.js
patronum.cjs.js.map
dist
.idea
34 changes: 0 additions & 34 deletions .scripts/rollup.js

This file was deleted.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "patronum",
"version": "1.2.0-next.0",
"version": "1.2.0-next.1",
"description": "☄️ Effector utility library delivering modularity and convenience",
"main": "patronum.cjs.js",
"main": "dist/patronum.cjs.js",
"types": "index.d.ts",
"browser": "dist/patronum.umd.js",
"scripts": {
"test": "yarn test:code && yarn test:types",
"test:code": "jest",
Expand All @@ -12,7 +13,7 @@
"format": "prettier --write \"./src/**/**.{ts,tsx,js,jsx,json}\"",
"lint": "eslint ./",
"build:methods": "node ./.scripts/build.js && prettier --config ./.prettierrc --write ./babel-plugin-factories.json",
"build:cjs": "node ./.scripts/rollup.js",
"build:cjs": "rollup -c",
"prepublishOnly": "yarn build:methods && yarn build:cjs"
},
"files": [
Expand All @@ -26,8 +27,7 @@
"library.js",
"macro.d.ts",
"macro.js",
"patronum.cjs.js.map",
"patronum.cjs.js"
"dist"
],
"repository": {
"type": "git",
Expand Down
45 changes: 45 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const path = require('path');
const { terser } = require('rollup-plugin-terser');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const commonjs = require('@rollup/plugin-commonjs');

const plugins = [
nodeResolve({ extensions: ['.js'] }),
commonjs({ extensions: ['.js'] }),
terser({}),
];

const input = 'index.js';

// eslint-disable-next-line import/no-anonymous-default-export
export default [
{
input,
external: ['effector'],
plugins,
output: {
file: 'patronum.cjs.js',
format: 'cjs',
freeze: false,
exports: 'named',
sourcemap: true,
externalLiveBindings: false,
},
},
{
input,
external: ['effector'],
plugins,
output: {
name: 'patronum',
file: 'patronum.umd.js',
format: 'umd',
exports: 'named',
sourcemap: true,
freeze: false,
globals: {
effector: 'effector',
},
},
},
];

0 comments on commit cded257

Please sign in to comment.