Skip to content

Commit

Permalink
fix: run babel on umd build
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 6, 2020
1 parent 49d2b6e commit fd7b271
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 19 deletions.
4 changes: 0 additions & 4 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-typescript'],
plugins: [
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-class-properties',
],
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
],
"main": "lib/index.js",
"module": "lib/index.es.js",
"browser": "lib/index.umd.js",
"umd:main": "lib/index.umd.js",
"types": "lib/index.d.ts",
"files": [
"lib/**/*",
Expand Down Expand Up @@ -52,6 +52,7 @@
"@babel/preset-env": "^7.9.6",
"@babel/preset-typescript": "^7.9.0",
"@release-it/conventional-changelog": "^1.1.4",
"@rollup/plugin-babel": "^5.0.0",
"@types/jest": "^25.2.1",
"@typescript-eslint/eslint-plugin": "^2.30.0",
"@typescript-eslint/parser": "^2.30.0",
Expand Down
30 changes: 17 additions & 13 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
import typescript from 'rollup-plugin-typescript2'
import babel from '@rollup/plugin-babel'
import pkg from './package.json'

export default {
const builds = {
cjs: {
output: { file: pkg.main },
},
es: { output: { file: pkg.module } },
umd: {
output: { file: pkg['umd:main'], name: 'sanityTypedQueries' },
plugins: [babel({ babelHelpers: 'bundled', extensions: ['.js', '.ts'] })],
},
}

export default Object.entries(builds).map(([format, build]) => ({
input: 'src/index.ts',
output: [
{
file: pkg.main,
format: 'cjs',
},
{
file: pkg.module,
format: 'es',
},
{
file: pkg.browser,
format: 'umd',
name: 'SanityTypedQueries',
format,
...build.output,
},
],
external: [
Expand All @@ -26,5 +29,6 @@ export default {
typescript({
typescript: require('typescript'),
}),
...(build.plugins || []),
],
}
}))
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
dependencies:
"@babel/types" "^7.8.3"

"@babel/helper-module-imports@^7.8.3":
"@babel/helper-module-imports@^7.7.4", "@babel/helper-module-imports@^7.8.3":
version "7.8.3"
resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.8.3.tgz#7fe39589b39c016331b6b8c3f441e8f0b1419498"
integrity sha512-R0Bx3jippsbAEtzkpZ/6FIiuzOURPcMjHp+Z6xPe6DtApDJx+w7UYyOLanZqO8+wKR9G10s/FmHXvxaMd9s6Kg==
Expand Down Expand Up @@ -1252,6 +1252,14 @@
prepend-file "^1.3.1"
release-it "^13.5.6"

"@rollup/plugin-babel@^5.0.0":
version "5.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.0.0.tgz#2f01c9555927449c82cb13dd9e56213a358e1ce9"
integrity sha512-YpVnwdUeVj/fDFN75Y3CAzJTMYNcqbH05SJs551wqj+BSwLT9pS3dqJrVDPYl3eH4OrI8ueiEseX5VgUn+0HLA==
dependencies:
"@babel/helper-module-imports" "^7.7.4"
"@rollup/pluginutils" "^3.0.8"

"@rollup/pluginutils@^3.0.8":
version "3.0.9"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.0.9.tgz#aa6adca2c45e5a1b950103a999e3cddfe49fd775"
Expand Down

0 comments on commit fd7b271

Please sign in to comment.