Skip to content

Commit

Permalink
fix: support typescript source files in library builds (#368)
Browse files Browse the repository at this point in the history
  • Loading branch information
amcgee committed Apr 24, 2020
1 parent 72a6262 commit 3ee69de
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
5 changes: 2 additions & 3 deletions cli/config/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const browserTargets = require('./.browserlistrc')
const jestTargets = { node: 'current' }

const isTest = process.env.NODE_ENV === 'test'
const targets = isTest ? jestTargets : browserTargets

const appBabelConfig = path.resolve(__dirname, 'app.babel.config')

Expand All @@ -16,8 +15,8 @@ module.exports = {
[
require('@babel/preset-env'),
{
modules: 'auto',
targets,
modules: isTest ? 'commonjs' : 'auto',
targets: isTest ? jestTargets : browserTargets,
},
],
],
Expand Down
12 changes: 8 additions & 4 deletions cli/config/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const replace = require('rollup-plugin-replace')
const visualize = require('rollup-plugin-visualizer')

const { reporter, chalk } = require('@dhis2/cli-helpers-engine')
const extensions = ['.js', '.jsx', '.ts', '.tsx']

const standardLibs = require('@dhis2/app-shell/package.json').dependencies

Expand Down Expand Up @@ -66,10 +67,6 @@ const bundle = ({
autoModules: false,
}),
json(),
babel({
configFile: require.resolve('./babel.config.js'),
exclude: /node_modules/, // only transpile our source code
}),
resolve({
/*
* TODO: Use of named exports (particularly `react-is` from `react-redux`)
Expand All @@ -79,8 +76,15 @@ const bundle = ({
* See https://github.com/rollup/rollup-plugin-commonjs/issues/211#issuecomment-337897124
*/
mainFields: ['browser', 'main'],
include: ['src/**/*'],
extensions,
}),
commonjs({ include: /node_modules/ }),
babel({
extensions,
configFile: require.resolve('./babel.config.js'),
exclude: /node_modules/, // only transpile our source code
}),
visualize({
filename: path.join(outDir, 'stats.html'),
title: 'DHIS2 Build Analysis',
Expand Down

0 comments on commit 3ee69de

Please sign in to comment.