Skip to content

Commit

Permalink
Generate TypeScript definitions.
Browse files Browse the repository at this point in the history
Closes #5
  • Loading branch information
leMaik committed Dec 12, 2017
1 parent f625f86 commit 38ab65b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions generate-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,19 @@ export default (props) => <SvgIcon {...props}>${svg}</SvgIcon>
presets: ['es2015', 'react', 'stage-0'],
compact: process.env.NODE_ENV === 'production'
}).code)

// typescript definition
fse.writeFileSync(path.join(__dirname, 'package', `${name}.d.ts`), `export { default } from 'material-ui/SvgIcon'
`)
}

// es2015 module syntax
const allExports = icons.map(({ name }) => `export { default as ${name} } from './${name}'`).join('\n')
fse.writeFileSync(path.join(__dirname, 'package', 'index.es.js'), allExports)

// typescript index definition (looks exactly the same)
fse.writeFileSync(path.join(__dirname, 'package', 'index.d.ts'), allExports)

// commonjs module
fse.writeFileSync(path.join(__dirname, 'package', 'index.js'), babel.transform(allExports, {
plugins: ['transform-es2015-modules-commonjs'],
Expand Down

0 comments on commit 38ab65b

Please sign in to comment.