Skip to content

Commit

Permalink
feat: adds rollup/plugin-typescript for build
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-kumawat committed Jul 22, 2020
1 parent 52ab440 commit 0066a55
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"build-css": "gulp --gulpfile css/gulpfile.js build",
"clean-css": "gulp --gulpfile css/gulpfile.js clean",
"watch-css": "gulp --gulpfile css/gulpfile.js build && gulp --gulpfile css/gulpfile.js watch",
"build-js": "rollup -c",
"build-js": "rm -rf dist/.lib && rollup -c",
"build-type": "rm -rf .lib && tsc -b tsconfig.type.json",
"build": "npm run build-css && npm run build-js && npm run build-type",
"build": "npm run build-css && npm run build-js",
"version": "./scripts/version.sh"
},
"author": "Innovaccer",
Expand All @@ -40,6 +40,7 @@
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@rollup/plugin-typescript": "^5.0.2",
"@storybook/addon-a11y": "^5.3.1",
"@storybook/addon-actions": "^5.2.8",
"@storybook/addon-docs": "^5.2.8",
Expand Down Expand Up @@ -87,8 +88,10 @@
"tslint-config-airbnb": "^5.11.2",
"tslint-config-prettier": "^1.18.0",
"tslint-react": "^4.1.0",
"ttypescript": "^1.5.10",
"typescript": "^3.7.4",
"typescript-eslint-parser": "^22.0.0"
"typescript-eslint-parser": "^22.0.0",
"typescript-transform-paths": "^1.1.14"
},
"dependencies": {
"@types/classnames": "^2.2.9",
Expand Down
42 changes: 39 additions & 3 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import alias from '@rollup/plugin-alias';
import json from '@rollup/plugin-json';
import path from 'path';
import packageJSON from './package.json';
import typescript from '@rollup/plugin-typescript';

const banner = () => {

Expand Down Expand Up @@ -46,7 +47,7 @@ function globals() {
};
}

export default {
export default [{
input: './core/index.tsx',

// Specify here external modules which you don't want to include in your bundle (for instance: 'lodash', 'moment' etc.)
Expand All @@ -59,6 +60,7 @@ export default {
{ find: '@', replacement: path.resolve('./core') },
]
}),

// Allows node_modules resolution
resolve({ extensions }),

Expand All @@ -74,8 +76,42 @@ export default {
output: formats.map(format => ({
file: `dist/index.${format}.js`,
format,
name: 'inno',
name: `inno-${format}`,
globals: globals(),
banner: banner(),
}))
};
}, {
input: './core/index.tsx',

external: ['react', 'react-dom', 'classnames', 'react-popper', 'axios', 'recharts'],

plugins: [
alias({
entries: [
{ find: '@', replacement: path.resolve('./core') },
]
}),

// Allows node_modules resolution
resolve({ extensions }),

typescript({
typescript: require('ttypescript'),
tsconfig: path.resolve(__dirname, './tsconfig.type.json'),
}),

// Allow bundling cjs modules. Rollup doesn't understand cjs
commonjs(),

// Compile TypeScript/JavaScript files
babel({ extensions, include: ['core/**/*'] }),
],

output: {
dir: 'dist',
format: 'umd',
name: `inno`,
globals: globals(),
banner: banner(),
}
}];
8 changes: 6 additions & 2 deletions tsconfig.type.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": ".lib",
"outDir": "dist/.lib",
"incremental": true,
"esModuleInterop": true,
"composite": true,
Expand All @@ -19,7 +19,11 @@
"@/*": [
"core/*"
]
}
},
"plugins": [
{ "transform": "typescript-transform-paths" },
{ "transform": "typescript-transform-paths", "afterDeclarations": true }
]
},
"exclude": [
"dist",
Expand Down

0 comments on commit 0066a55

Please sign in to comment.