Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move core source to scoped package, use "redux-saga" only as proxy to…
… it (#1712) * Move core source to scoped package, use "redux-saga" only as proxy to it * Workaround for rollup/rollup#2620 * Use distinct filenames for redux-saga proxy package * Add missing default reexport in redux-saga index.d.ts
- Loading branch information
Showing
18 changed files
with
224 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,6 @@ | |
"source-map": "^0.6.1" | ||
}, | ||
"peerDependencies": { | ||
"redux-saga": "^1.0.0-beta.0" | ||
"redux-saga": "^1.0.0-rc.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { NODE_ENV, BABEL_ENV } = process.env | ||
|
||
const cjs = BABEL_ENV === 'cjs' || NODE_ENV === 'test' | ||
const loose = true | ||
|
||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
loose, | ||
modules: false, | ||
forceAllTransforms: true, | ||
exclude: ['transform-regenerator'], | ||
}, | ||
], | ||
], | ||
plugins: [ | ||
cjs && '@babel/plugin-transform-modules-commonjs', | ||
['@babel/plugin-proposal-object-rest-spread', { loose }], | ||
'babel-plugin-annotate-pure-calls', | ||
].filter(Boolean), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@redux-saga/core/effects' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "redux-saga/effects", | ||
"private": true, | ||
"main": "../dist/redux-saga-effects.cjs.js", | ||
"module": "../dist/redux-saga-effects.esm.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from '@redux-saga/core' | ||
export { default } from '@redux-saga/core' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{ | ||
"name": "redux-saga", | ||
"version": "1.0.0-rc.0", | ||
"description": "Saga middleware for Redux to handle Side Effects", | ||
"main": "./dist/redux-saga-core.cjs.js", | ||
"module": "./dist/redux-saga-core.esm.js", | ||
"unpkg": "./dist/redux-saga.umd.min.js", | ||
"files": [ | ||
"dist", | ||
"effects", | ||
"*.d.ts" | ||
], | ||
"scripts": { | ||
"bundlesize": "bundlesize", | ||
"clean": "rimraf dist", | ||
"prebuild": "npm run clean", | ||
"build": "rollup -c", | ||
"prepare": "npm run build" | ||
}, | ||
"repository": "https://github.com/redux-saga/redux-saga/tree/master/packages/core", | ||
"keywords": [ | ||
"javascript", | ||
"redux", | ||
"middleware", | ||
"saga", | ||
"effects", | ||
"side effects" | ||
], | ||
"bundlesize": [ | ||
{ | ||
"path": "./dist/redux-saga.min.umd.js", | ||
"maxSize": "6.5 Kb" | ||
} | ||
], | ||
"author": "Yassine ELOUAFI <yelouafi@gmail.com>", | ||
"contributors": [ | ||
"Mateusz Burzyński <mateuszburzynski@gmail.com> (https://github.com/Andarist)", | ||
"Mikhail Shustov <restrry@gmail.com> (https://github.com/restrry)", | ||
"Shi Feichao <842351815@qq.com> (https://github.com/shinima)", | ||
"Daniel Lytkin <dan.lytkin@gmail.com (https://github.com/aikoven)" | ||
], | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/redux-saga/redux-saga/issues" | ||
}, | ||
"homepage": "https://redux-saga.js.org/", | ||
"dependencies": { | ||
"@redux-saga/core": "^1.0.0-rc.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.0.0", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.0.0", | ||
"@babel/plugin-transform-runtime": "^7.0.0", | ||
"@babel/polyfill": "^7.0.0", | ||
"@babel/preset-env": "^7.0.0", | ||
"bundlesize": "^0.11.0", | ||
"lerna-alias": "^3.0.2", | ||
"rimraf": "^2.4.3", | ||
"rollup": "^0.65.2", | ||
"rollup-plugin-alias": "^1.4.0", | ||
"rollup-plugin-babel": "^4.0.3", | ||
"rollup-plugin-node-resolve": "^3.0.0", | ||
"rollup-plugin-replace": "^1.1.1", | ||
"rollup-plugin-uglify": "^2.0.1" | ||
}, | ||
"typings": "./index.d.ts", | ||
"npmName": "redux-saga", | ||
"npmFileMap": [ | ||
{ | ||
"basePath": "/dist/", | ||
"files": [ | ||
"*.js" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import * as path from 'path' | ||
import alias from 'rollup-plugin-alias' | ||
import nodeResolve from 'rollup-plugin-node-resolve' | ||
import babel from 'rollup-plugin-babel' | ||
import replace from 'rollup-plugin-replace' | ||
import uglify from 'rollup-plugin-uglify' | ||
import { rollup as lernaAlias } from 'lerna-alias' | ||
import pkg from './package.json' | ||
|
||
const ensureArray = maybeArr => (Array.isArray(maybeArr) ? maybeArr : [maybeArr]) | ||
|
||
const makeExternalPredicate = externalArr => { | ||
if (!externalArr.length) { | ||
return () => false | ||
} | ||
const pattern = new RegExp(`^(${externalArr.join('|')})($|/)`) | ||
return id => pattern.test(id) | ||
} | ||
|
||
const deps = Object.keys(pkg.dependencies || {}) | ||
const peerDeps = Object.keys(pkg.peerDependencies || {}) | ||
|
||
let aliases = lernaAlias() | ||
aliases = { | ||
'@redux-saga/core/effects': aliases['@redux-saga/core'].replace(/index\.js$/, 'effects.js'), | ||
'@babel/runtime/helpers/extends': require.resolve('@babel/runtime/helpers/esm/extends'), | ||
...aliases, | ||
} | ||
|
||
const createConfig = ({ input, output, external, env, min = false }) => ({ | ||
input, | ||
experimentalCodeSplitting: typeof input !== 'string', | ||
output: ensureArray(output).map(format => ({ | ||
name: 'ReduxSaga', | ||
exports: 'named', | ||
...format, | ||
})), | ||
external: makeExternalPredicate(external === 'peers' ? peerDeps : deps.concat(peerDeps)), | ||
plugins: [ | ||
alias(aliases), | ||
nodeResolve({ | ||
jsnext: true, | ||
}), | ||
babel({ | ||
exclude: 'node_modules/**', | ||
babelrcRoots: path.resolve(__dirname, '../*'), | ||
}), | ||
env && | ||
replace({ | ||
'process.env.NODE_ENV': JSON.stringify(env), | ||
}), | ||
min && | ||
uglify({ | ||
compress: { | ||
pure_getters: true, | ||
unsafe: true, | ||
unsafe_comps: true, | ||
warnings: false, | ||
}, | ||
}), | ||
].filter(Boolean), | ||
}) | ||
|
||
export default [ | ||
createConfig({ | ||
input: { | ||
core: 'src/index.js', | ||
effects: 'src/effects.js', | ||
}, | ||
output: [ | ||
{ | ||
dir: 'dist', | ||
format: 'esm', | ||
}, | ||
{ | ||
dir: 'dist', | ||
format: 'cjs', | ||
}, | ||
].map(format => ({ entryFileNames: 'redux-saga-[name]-npm-proxy.[format].js', ...format })), | ||
}), | ||
createConfig({ | ||
input: 'src/index.umd.js', | ||
output: { | ||
file: pkg.unpkg.replace(/\.min\.js$/, '.js'), | ||
format: 'umd', | ||
}, | ||
external: 'peers', | ||
env: 'development', | ||
}), | ||
createConfig({ | ||
input: 'src/index.umd.js', | ||
output: { | ||
file: pkg.unpkg, | ||
format: 'umd', | ||
}, | ||
external: 'peers', | ||
env: 'production', | ||
min: true, | ||
}), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from '@redux-saga/core/effects' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from '@redux-saga/core' | ||
import createSagaMiddleware from '@redux-saga/core' | ||
export default createSagaMiddleware |
File renamed without changes.
Oops, something went wrong.