-
Notifications
You must be signed in to change notification settings - Fork 23
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
4 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,118 @@ | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import typescript from '@rollup/plugin-typescript'; | ||
import * as dts from 'rollup-plugin-dts'; | ||
import terser from '@rollup/plugin-terser' | ||
import peerDepsExternal from 'rollup-plugin-peer-deps-external'; | ||
import jsx from 'acorn-jsx'; | ||
import postcss from 'rollup-plugin-postcss' | ||
import json from '@rollup/plugin-json'; | ||
import svg from 'rollup-plugin-svg' | ||
import { babel } from '@rollup/plugin-babel'; | ||
console.log(`babel: `, babel); | ||
|
||
import packageJson from './package.json' assert { type: 'json' } | ||
|
||
import { basename, dirname, isAbsolute } from 'path'; | ||
import * as fs from 'fs'; | ||
|
||
function isFile ( file ) { | ||
try { | ||
return fs.statSync( file ).isFile(); | ||
} catch ( err ) { | ||
return false; | ||
} | ||
} | ||
|
||
function addExtensionIfNecessary ( file, extensions ) { | ||
try { | ||
const name = basename( file ); | ||
const files = fs.readdirSync( dirname( file ) ); | ||
|
||
if ( ~files.indexOf( name ) && isFile( file ) ) return file; | ||
for ( const ext of extensions ) { | ||
if ( ~files.indexOf( `${name}${ext}` ) && isFile( `${file}${ext}` ) ) { | ||
return `${file}${ext}`; | ||
} | ||
} | ||
} catch ( err ) { | ||
// noop | ||
} | ||
|
||
return null; | ||
} | ||
|
||
function extensions ({extensions}) { | ||
if (!extensions || !extensions.length) { | ||
throw new Error( `Must specify { extensions: [..] } as non-empty array!` ); | ||
} | ||
|
||
return { | ||
name: 'extensions', | ||
|
||
resolveId ( importee, importer ) { | ||
// absolute paths are left untouched | ||
if ( isAbsolute( importee ) ) { | ||
return addExtensionIfNecessary( resolve( importee ), extensions ); | ||
} | ||
|
||
// if this is the entry point, resolve against cwd | ||
if ( importer === undefined ) { | ||
return addExtensionIfNecessary( resolve( process.cwd(), importee ), extensions ); | ||
} | ||
|
||
// external modules are skipped at this stage | ||
if ( importee[0] !== '.' ) return null; | ||
|
||
return addExtensionIfNecessary( resolve( dirname( importer ), importee ), extensions ); | ||
} | ||
}; | ||
} | ||
|
||
export default [ | ||
{ | ||
input: 'src/index.js', | ||
// dir: 'dist', | ||
output: [ | ||
{ | ||
// file: packageJson.module, | ||
dir: 'dist/cjs', | ||
format: 'cjs', | ||
sourcemap: true | ||
} | ||
], | ||
// acornInjectPlugins: [jsx()], | ||
|
||
plugins: [ | ||
resolve({extensions: ['.js', '.jsx', '.ts', '.tsx']}), | ||
babel({ babelHelpers: 'bundled', extensions: [".js", ".jsx"] }), | ||
// extensions({ | ||
// extensions: [ '.jsx', '.js'], | ||
// }), | ||
|
||
// 'src/components/object-info/LinksTable.css', | ||
// 'src/components/loader/Loader.css' | ||
// postcss({ | ||
// include: "src/components/object-info/LinksTable.css", | ||
// extract: resolve('dist/cjs/components/object-info/LinksTable.css') | ||
// }), | ||
// postcss({ | ||
// include: "src/components/loader/Loader.css", | ||
// extract: resolve('dist/cjs/components/loader/Loader.css') | ||
// }), | ||
|
||
// peerDepsExternal(), | ||
// json(), | ||
// svg(), | ||
// commonjs(), | ||
// typescript({ tsconfig: './tsconfig.rollup.json' }), | ||
// terser(), | ||
], | ||
external: ['react', 'react-dom', 'styled-components'] | ||
}, | ||
{ | ||
input: 'src/index.ts', | ||
output: [{ file: 'dist/cjs/types.d.ts', format: 'es' }], | ||
plugins: [dts.default()] | ||
} | ||
] |
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,56 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ESNext", | ||
"lib": [ | ||
"dom", | ||
"dom.iterable", | ||
"es2017", | ||
"esnext" | ||
], | ||
// "types": [ | ||
// "vite/client", | ||
// "vite-plugin-svgr/client" | ||
// ], | ||
"allowJs": true, | ||
"skipLibCheck": true, | ||
"esModuleInterop": true, | ||
"allowSyntheticDefaultImports": true, | ||
"strict": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"module": "CommonJS", | ||
// "moduleResolution": "bundler", | ||
"resolveJsonModule": true, | ||
"isolatedModules": true, | ||
"noEmit": false, | ||
"outDir": "dist/cjs", | ||
"declaration": true, | ||
"declarationDir": "dist/cjs", | ||
"jsx": "react", | ||
"rootDir": "src", | ||
"emitDeclarationOnly": false, | ||
// "allowImportingTsExtensions": true, | ||
// "jsxImportSource": "react" | ||
|
||
}, | ||
// "include": [ | ||
// "**/*.js", | ||
|
||
// ], | ||
"exclude": [ | ||
"src/*/*.test.*", | ||
"node_modules", | ||
"src/devPage.jsx", | ||
"storybook-static", | ||
"build", | ||
"dist", | ||
"custom-jest-env.js", | ||
"vite.config.ts", | ||
"src/**/*.stories.*", | ||
"jest.config.js", | ||
"rollup.config.mjs", | ||
"webpack.config.js", | ||
"package.json", | ||
"dev" | ||
] | ||
} |