Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support typescript source files in library builds #368

Merged
merged 1 commit into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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