This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
240 additions
and
51 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/dist |
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 @@ | ||
/dist |
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,29 @@ | ||
const fs = require('fs'); | ||
const { cp, rm } = require('shelljs'); | ||
|
||
if (fs.existsSync('dist/ts-4.1')) { | ||
rm('-r', 'dist/ts-4.1'); | ||
} | ||
|
||
cp('-r', 'dist/ts/', 'dist/ts-4.1'); | ||
|
||
const stubTs41Types = ` | ||
import { EndpointDefinitions } from './endpointDefinitions'; | ||
export declare type TS41Hooks<Definitions extends EndpointDefinitions> = unknown; | ||
export {}; | ||
`; | ||
|
||
fs.writeFileSync('dist/ts/ts41Types.d.ts', stubTs41Types); | ||
|
||
fs.writeFileSync( | ||
'dist/index.js', | ||
` | ||
'use strict' | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./index.cjs.production.min.js') | ||
} else { | ||
module.exports = require('./index.cjs.development.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,99 @@ | ||
import babel from '@rollup/plugin-babel'; | ||
import typescript from '@rollup/plugin-typescript'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import replace from '@rollup/plugin-replace'; | ||
|
||
/** @type {import("rollup").RollupOptions} */ | ||
const defaultConfig = { | ||
input: 'src/index.ts', | ||
external: [/@babel\/runtime/, /@reduxjs\/toolkit/, /react$/, /react-redux/, /immer/, /tslib/], | ||
treeshake: { | ||
propertyReadSideEffects: false, | ||
}, | ||
}; | ||
|
||
const defaultTerserOptions = { | ||
output: { comments: false }, | ||
compress: { | ||
keep_infinity: true, | ||
pure_getters: true, | ||
passes: 10, | ||
}, | ||
ecma: 5, | ||
warnings: true, | ||
}; | ||
|
||
const defaultTsConfig = { declaration: false, declarationMap: false, target: 'ESNext', module: 'esnext' }; | ||
|
||
/** @type {import("rollup").RollupOptions} */ | ||
const configs = [ | ||
// ESM | ||
{ | ||
...defaultConfig, | ||
output: [ | ||
{ | ||
dir: 'dist/esm', | ||
format: 'es', | ||
sourcemap: true, | ||
preserveModules: true, | ||
}, | ||
], | ||
plugins: [ | ||
typescript(defaultTsConfig), | ||
babel({ | ||
exclude: 'node_modules/**', | ||
extensions: ['.js', '.ts'], | ||
babelHelpers: 'runtime', | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
targets: { node: true, browsers: ['defaults', 'not IE 11', 'maintained node versions'] }, | ||
bugfixes: true, | ||
loose: true, | ||
}, | ||
], | ||
], | ||
plugins: [['@babel/plugin-transform-runtime', { useESModules: true }]], | ||
}), | ||
], | ||
}, | ||
// CJS: | ||
...withMinify((minified) => ({ | ||
...defaultConfig, | ||
output: [ | ||
{ | ||
dir: 'dist', | ||
format: 'cjs', | ||
sourcemap: true, | ||
entryFileNames: minified ? '[name].cjs.production.min.js' : '[name].cjs.development.js', | ||
}, | ||
], | ||
plugins: [ | ||
typescript( | ||
minified | ||
? defaultTsConfig | ||
: { ...defaultTsConfig, declarationDir: 'dist/ts', declaration: true, declarationMap: true } | ||
), | ||
replace({ | ||
values: { | ||
'process.env.NODE_ENV': JSON.stringify(minified ? 'production' : 'development'), | ||
}, | ||
}), | ||
babel({ | ||
exclude: 'node_modules/**', | ||
extensions: ['.js', '.ts'], | ||
babelHelpers: 'runtime', | ||
presets: [['@babel/preset-env', { targets: { node: true, browsers: ['defaults'] } }]], | ||
plugins: [['@babel/plugin-transform-runtime', { useESModules: false }]], | ||
}), | ||
...(minified ? [terser({ ...defaultTerserOptions, toplevel: true })] : []), | ||
], | ||
})), | ||
]; | ||
|
||
function withMinify(build) { | ||
return [build(false), build(true)]; | ||
} | ||
|
||
export default configs; |
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 class HandledError { | ||
constructor(public readonly value: any) {} | ||
} |
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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.