-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite build steps and update output
- Updated all "build:x" scripts based on React-Redux package - Added tsconfig and TS types output, and moved TS output to ./es - Added Babel compilation of TS syntax
- Loading branch information
1 parent
f51d54b
commit f2dcde3
Showing
7 changed files
with
104 additions
and
21 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 |
---|---|---|
@@ -1,8 +1,19 @@ | ||
const { BABEL_ENV, NODE_ENV } = process.env | ||
const cjs = BABEL_ENV === 'cjs' || NODE_ENV === 'test' | ||
const { NODE_ENV, BABEL_ENV } = process.env | ||
const cjs = NODE_ENV === 'test' || BABEL_ENV === 'commonjs' | ||
|
||
module.exports = { | ||
presets: [ | ||
['@babel/env', { loose: true, modules: cjs ? 'cjs' : false }] | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { | ||
ie: 11 | ||
}, | ||
loose: true, | ||
modules: cjs ? 'cjs' : false | ||
} | ||
], | ||
'@babel/preset-typescript' | ||
], | ||
plugins: [cjs && ['@babel/transform-modules-commonjs']].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,4 @@ | ||
lib | ||
es | ||
dist | ||
node_modules |
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 |
---|---|---|
@@ -1,15 +1,48 @@ | ||
import nodeResolve from '@rollup/plugin-node-resolve' | ||
import babel from '@rollup/plugin-babel' | ||
import replace from '@rollup/plugin-replace' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import { terser } from 'rollup-plugin-terser' | ||
|
||
export default { | ||
input: 'src/index.js', | ||
const env = process.env.NODE_ENV | ||
|
||
const extensions = ['.js', '.ts', '.tsx', '.json'] | ||
|
||
const config = { | ||
input: 'src/index.ts', | ||
output: { | ||
file: 'dist/reselect.js', | ||
format: 'umd', | ||
name: 'Reselect' | ||
}, | ||
plugins: [ | ||
nodeResolve({ | ||
extensions | ||
}), | ||
babel({ | ||
babelHelpers: 'bundled' | ||
}) | ||
include: 'src/**/*', | ||
exclude: '**/node_modules/**', | ||
babelHelpers: 'bundled', | ||
extensions | ||
}), | ||
replace({ | ||
'process.env.NODE_ENV': JSON.stringify(env), | ||
preventAssignment: true | ||
}), | ||
commonjs() | ||
] | ||
} | ||
|
||
if (env === 'production') { | ||
config.plugins.push( | ||
terser({ | ||
compress: { | ||
pure_getters: true, | ||
unsafe: true, | ||
unsafe_comps: true, | ||
warnings: false | ||
} | ||
}) | ||
) | ||
} | ||
|
||
export default config |
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,21 @@ | ||
{ | ||
"compilerOptions": { | ||
"strict": true, | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"esModuleInterop": true, | ||
"skipLibCheck": true, | ||
"allowJs": true, | ||
"jsx": "react", | ||
"declaration": true, | ||
"emitDeclarationOnly": true, | ||
"outDir": "./es", | ||
"forceConsistentCasingInFileNames": true, | ||
"experimentalDecorators": true, | ||
"rootDirs": ["./src", "./test"], | ||
"rootDir": "./src", | ||
}, | ||
"include": ["src/**/*", "typescript-test/**/*"], | ||
"exclude": ["node_modules", "dist"] | ||
} |