Skip to content

Commit

Permalink
chore(build): split rollup configs for main & module
Browse files Browse the repository at this point in the history
Split rollup config into separate files so the babel plugin `add-module-exports` can be excluded for the .mjs output.
  • Loading branch information
citycide committed Jul 25, 2017
1 parent 9befc5d commit e1d57c3
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 32 deletions.
38 changes: 6 additions & 32 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,7 @@
import babel from 'rollup-plugin-babel'
import mainConfig from './rollup.config.main'
import moduleConfig from './rollup.config.module'

const pkg = require('./package.json')
const external = Object.keys(pkg.dependencies)
.concat(['fs', 'path', 'sql.js'])

export default {
entry: 'src/index.js',
external,
plugins: [
babel({
babelrc: false,
presets: [['env', {
loose: true,
modules: false,
targets: { node: "4.7.0" }
}], 'stage-0'],
plugins: [
'external-helpers',
'add-module-exports'
],
runtimeHelpers: false,
exclude: 'node_modules/**'
})
],
targets: [{
dest: pkg.main,
format: 'cjs'
}, {
dest: pkg.module,
format: 'es'
}]
}
export default [
mainConfig,
moduleConfig
]
30 changes: 30 additions & 0 deletions rollup.config.main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import babel from 'rollup-plugin-babel'

const pkg = require('./package.json')
const external = Object.keys(pkg.dependencies)
.concat(['fs', 'path', 'sql.js'])

export default {
entry: 'src/index.js',
external,
plugins: [
babel({
babelrc: false,
presets: [['env', {
loose: true,
modules: false,
targets: { node: '4.7.0' }
}], 'stage-0'],
plugins: [
'external-helpers',
'add-module-exports'
],
runtimeHelpers: false,
exclude: 'node_modules/**'
})
],
targets: [{
dest: pkg.main,
format: 'cjs'
}]
}
29 changes: 29 additions & 0 deletions rollup.config.module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import babel from 'rollup-plugin-babel'

const pkg = require('./package.json')
const external = Object.keys(pkg.dependencies)
.concat(['fs', 'path', 'sql.js'])

export default {
entry: 'src/index.js',
external,
plugins: [
babel({
babelrc: false,
presets: [['env', {
loose: true,
modules: false,
targets: { node: '4.7.0' }
}], 'stage-0'],
plugins: [
'external-helpers'
],
runtimeHelpers: false,
exclude: 'node_modules/**'
})
],
targets: [{
dest: pkg.module,
format: 'es'
}]
}

0 comments on commit e1d57c3

Please sign in to comment.