-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
16 changed files
with
3,129 additions
and
3,449 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,24 @@ | ||
/* eslint-env node */ | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const pkg = require('./package.json'); | ||
|
||
module.exports = { | ||
plugins: ['@typescript-eslint', 'prettier'], | ||
extends: [ | ||
'react-app', | ||
'plugin:@typescript-eslint/recommended', | ||
'plugin:prettier/recommended', | ||
'prettier/@typescript-eslint', | ||
], | ||
settings: { | ||
react: { | ||
version: pkg.devDependencies.react ? 'detect' : '99.99.99', | ||
}, | ||
}, | ||
rules: { | ||
'@typescript-eslint/explicit-module-boundary-types': 'off', | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'@typescript-eslint/no-non-null-assertion': 'off', | ||
}, | ||
}; |
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,2 +1,15 @@ | ||
/.pnp.js | ||
/.yarnrc.yml | ||
/.yarnrc.yml | ||
/.yarn | ||
/build | ||
/docs | ||
/coverage | ||
/.gitattributes | ||
/.gitignore | ||
/.prettierignore | ||
/LICENSE | ||
/yarn.lock | ||
/.vscode | ||
*.map | ||
samples/*.js | ||
src/**/*.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
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,7 +1 @@ | ||
packageExtensions: | ||
'tsdx@*': | ||
dependencies: | ||
'babel-jest': '^25.5.1' | ||
'eslint-config-react-app@*': | ||
dependencies: | ||
'babel-eslint': '*' | ||
# packageExtensions: |
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 @@ | ||
/* eslint-env node */ | ||
|
||
module.exports = { | ||
preset: 'ts-jest', | ||
testRegex: '((\\.|/)(test|spec))\\.[jt]sx?$', | ||
}; |
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,109 @@ | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import dts from 'rollup-plugin-dts'; | ||
import typescript from '@rollup/plugin-typescript'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import replace from '@rollup/plugin-replace'; | ||
import babel from '@rollup/plugin-babel'; | ||
|
||
import fs from 'fs'; | ||
|
||
const pkg = JSON.parse(fs.readFileSync('./package.json')); | ||
|
||
const banner = `/** | ||
* ${pkg.name} | ||
* ${pkg.homepage} | ||
* | ||
* Copyright (c) ${new Date().getFullYear()} ${pkg.author.name} <${pkg.author.email}> | ||
*/ | ||
`; | ||
|
||
/** | ||
* defines which formats (umd, esm, cjs, types) should be built when watching | ||
*/ | ||
const watchOnly = ['umd']; | ||
|
||
const isDependency = (v) => Object.keys(pkg.dependencies || {}).some((e) => e === v || v.startsWith(e + '/')); | ||
const isPeerDependency = (v) => Object.keys(pkg.peerDependencies || {}).some((e) => e === v || v.startsWith(e + '/')); | ||
|
||
export default function Config(options) { | ||
const buildFormat = (format) => !options.watch || watchOnly.includes(format); | ||
|
||
const base = { | ||
input: './src/index.ts', | ||
output: { | ||
sourcemap: true, | ||
banner, | ||
exports: 'named', | ||
globals: { | ||
cytoscape: 'cytoscape', | ||
'cytoscape-layers': 'CytoscapeLayers', | ||
crypto: 'NodeCrypto', | ||
}, | ||
}, | ||
external: (v) => isDependency(v) || isPeerDependency(v), | ||
plugins: [ | ||
typescript(), | ||
resolve(), | ||
commonjs(), | ||
replace({ | ||
// eslint-disable-next-line no-undef | ||
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV) || 'production', | ||
__VERSION__: JSON.stringify(pkg.version), | ||
}), | ||
], | ||
}; | ||
return [ | ||
(buildFormat('esm') || buildFormat('cjs')) && { | ||
...base, | ||
output: [ | ||
buildFormat('esm') && { | ||
...base.output, | ||
file: pkg.module, | ||
format: 'esm', | ||
}, | ||
buildFormat('cjs') && { | ||
...base.output, | ||
file: pkg.main, | ||
format: 'cjs', | ||
}, | ||
].filter(Boolean), | ||
}, | ||
((buildFormat('umd') && pkg.browser) || (buildFormat('umd-min') && pkg.unpkg)) && { | ||
...base, | ||
input: fs.existsSync(base.input.replace('.ts', '.umd.ts')) ? base.input.replace('.ts', '.umd.ts') : base.input, | ||
output: [ | ||
buildFormat('umd') && | ||
pkg.browser && { | ||
...base.output, | ||
file: pkg.browser, | ||
format: 'umd', | ||
name: pkg.global, | ||
}, | ||
buildFormat('umd-min') && | ||
pkg.unpkg && { | ||
...base.output, | ||
file: pkg.unpkg, | ||
format: 'umd', | ||
name: pkg.global, | ||
plugins: [terser()], | ||
}, | ||
].filter(Boolean), | ||
external: (v) => isPeerDependency(v), | ||
plugins: [...base.plugins, babel({ presets: ['@babel/env'], babelHelpers: 'bundled' })], | ||
}, | ||
buildFormat('types') && { | ||
...base, | ||
output: { | ||
...base.output, | ||
file: pkg.types, | ||
format: 'es', | ||
}, | ||
plugins: [ | ||
dts({ | ||
respectExternal: true, | ||
}), | ||
], | ||
}, | ||
].filter(Boolean); | ||
} |
Oops, something went wrong.