-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
2,156 additions
and
72 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,5 @@ | ||
const plugin = require('babel-preset-fbjs/plugins/dev-expression'); | ||
|
||
module.exports = { | ||
plugins: [plugin] | ||
} |
Large diffs are not rendered by default.
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 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,5 @@ | ||
module.exports = { | ||
files: 'lib/**/*.*', | ||
from: /import \* as /g, | ||
to: 'import ', | ||
}; |
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,97 @@ | ||
/* eslint-disable @typescript-eslint/explicit-function-return-type */ | ||
/* eslint-disable @typescript-eslint/camelcase */ | ||
/* eslint-disable import/no-default-export */ | ||
import babel from '@rollup/plugin-babel'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import nodeResolve from '@rollup/plugin-node-resolve'; | ||
import replace from '@rollup/plugin-replace'; | ||
import sourceMaps from 'rollup-plugin-sourcemaps'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import typescript from 'rollup-plugin-typescript2'; | ||
import pkg from './package.json'; | ||
|
||
const makeExternalPredicate = (externalArr) => { | ||
if (externalArr.length === 0) { | ||
return () => false; | ||
} | ||
const pattern = new RegExp(`^(${externalArr.join('|')})($|/)`); | ||
return (id) => pattern.test(id); | ||
}; | ||
|
||
const extensions = ['.ts', '.tsx']; | ||
|
||
function createConfigInternal({ format, production }) { | ||
return { | ||
input: 'src/index.ts', | ||
output: { | ||
file: 'lib/' + format + '/relay-forms' + (production ? '.min' : '') + '.js', | ||
format, | ||
name: 'relay-forms', | ||
indent: false, | ||
globals: { | ||
'fbjs/lib/areEqual': 'areEqual', | ||
'fbjs/lib/invariant': 'invariant', | ||
'fbjs/lib/warning': 'warning', | ||
'@restart/hooks/useMounted': 'useMounted', | ||
react: 'React', | ||
'relay-runtime': 'relayRuntime', | ||
}, | ||
sourcemap: true, | ||
exports: 'named', | ||
}, | ||
external: makeExternalPredicate([ | ||
...Object.keys(pkg.dependencies || {}), | ||
...Object.keys(pkg.peerDependencies || {}), | ||
]), | ||
plugins: [ | ||
nodeResolve({ | ||
extensions, | ||
}), | ||
replace({ | ||
'import * as ': 'import ', | ||
}), | ||
typescript({ | ||
tsconfigOverride: { | ||
compilerOptions: { | ||
declaration: false, | ||
declarationMap: false, | ||
module: 'es2015', | ||
esModuleInterop: true, | ||
sourceMap: true, | ||
importHelpers: false, | ||
}, | ||
}, | ||
}), | ||
format === 'umd' && | ||
commonjs({ | ||
include: /\/node_modules\//, | ||
}), | ||
babel({ extensions, include: ['src/**/*'], babelHelpers: 'bundled' }), | ||
replace({ | ||
'process.env.NODE_ENV': JSON.stringify(production ? 'production' : 'development'), | ||
}), | ||
sourceMaps(), | ||
production && | ||
terser({ | ||
output: { comments: false }, | ||
compress: { | ||
keep_infinity: true, | ||
pure_getters: true, | ||
passes: 10, | ||
}, | ||
ecma: 5, | ||
toplevel: format === 'cjs', | ||
warnings: true, | ||
}), | ||
], | ||
}; | ||
} | ||
|
||
function createConfig(format) { | ||
return [ | ||
createConfigInternal({ format, production: false }), | ||
createConfigInternal({ format, production: true }), | ||
]; | ||
} | ||
|
||
export default [...createConfig('umd')]; |
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,7 @@ | ||
{ | ||
"extends": "./tsconfig.json", | ||
"compilerOptions": { | ||
"module": "ESNext", | ||
"outDir": "./lib/es" | ||
}, | ||
} |