Skip to content

Commit

Permalink
feat: add cjs/esm/es2015 bundle via @1stg/rollup-config
Browse files Browse the repository at this point in the history
  • Loading branch information
JounQin committed Sep 3, 2019
1 parent 48bb2ee commit 93e4786
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
coverage
node_modules
/index.js
/cjs.js
/es2015.js
/esm.js
# Babel parse issue, ignore temporarily
test/private-methods.ts
21 changes: 14 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
const { resolve } = require('path')
const { jest, js } = require('@1stg/eslint-config/overrides')
const { dTs, jest, js, ts } = require('@1stg/eslint-config/overrides')
const { merge } = require('lodash')

module.exports = {
extends: ['@1stg', 'plugin:import/typescript'],
parser: 'babel-eslint',
parserOptions: {
babelOptions: {
configFile: resolve('.babelrc.js'),
},
},
settings: {
'import/ignore': [/test\/private-methods.ts$/],
'import/parsers': {
Expand All @@ -21,9 +17,20 @@ module.exports = {
},
overrides: [
{
files: '*.{js,ts}',
...js,
files: '*.{js,ts}',
},
merge({}, ts, dTs, {
files: '*.d.ts',
rules: {
'prettier/prettier': [
2,
{
parser: 'typescript',
},
],
},
}),
jest,
],
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
*.log
coverage
node_modules
/index.js
/cjs.js
/es2015.js
/esm.js
2 changes: 1 addition & 1 deletion .babelrc.js → babel.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
module.exports = {
presets: [
'proposal-typescript',
[
'@babel/env',
{
Expand All @@ -10,5 +9,6 @@ module.exports = {
},
],
'@babel/typescript',
'proposal-typescript',
],
}
File renamed without changes.
10 changes: 9 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
module.exports = {
transform: {
'^.+\\.[t|j]sx?$': 'babel-jest',
'^.+\\.[jt]s$': 'babel-jest',
},
collectCoverage: true,
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
}
13 changes: 9 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"name": "babel-preset-proposal-typescript",
"version": "1.2.6",
"version": "1.3.0",
"description": "Yet another Babel preset for TypeScript, only transforms proposals which TypeScript does not support now.",
"module": "esm.js",
"repository": "git@github.com/rx-ts/babel-preset-proposal-typescript.git",
"author": "JounQin <admin@1stg.me>",
"license": "MIT",
"main": "cjs.js",
"module": "esm.js",
"es2015": "es2015.js",
"scripts": {
"build": "babel --no-babelrc --presets @babel/env esm.js > index.js",
"build": "rollup -c",
"lint": "EFF_NO_LINK_RULES=true eslint . --ext .js,.ts -f friendly",
"pretest": "yarn build",
"test": "jest",
Expand All @@ -23,8 +25,9 @@
"typescript"
],
"files": [
"cjs.js",
"esm.js",
"index.js"
"es2015.js"
],
"peerDependencies": {
"@babel/core": "^7.0.0",
Expand Down Expand Up @@ -53,6 +56,7 @@
"@1stg/husky-config": "^0.3.0",
"@1stg/lint-staged": "^0.5.0",
"@1stg/prettier-config": "^0.2.0",
"@1stg/rollup-config": "^0.3.0",
"@1stg/tsconfig": "^0.3.0",
"@babel/cli": "^7.5.5",
"@babel/core": "^7.5.5",
Expand All @@ -71,6 +75,7 @@
"jest": "^24.9.0",
"lint-staged": "^9.2.5",
"prettier": "^1.18.2",
"rollup": "^1.20.3",
"typescript": "^3.6.2"
}
}
5 changes: 5 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import config from '@1stg/rollup-config/cjs'

export default config({
formats: ['cjs', 'esm', 'es2015'],
})
1 change: 1 addition & 0 deletions test/function-bind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const bigBox = { weight: 10 }

// Can be chained:
function add(val: number) {
// eslint-disable-next-line babel/no-invalid-this
return this + val
}

Expand Down
3 changes: 3 additions & 0 deletions test/nullish-coalescing-operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ export default () => {
const undefinedValue =
response.settings?.undefinedValue ?? 'some other default'
const nullValue = response.settings?.nullValue ?? 'some other default'
// istanbul ignore next
const headerText = response.settings?.headerText ?? 'Hello, world!'
// istanbul ignore next
const animationDuration = response.settings?.animationDuration ?? 300
// istanbul ignore next
const showSplashScreen = response.settings?.showSplashScreen ?? true

return [
Expand Down
80 changes: 77 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
resolved "https://registry.yarnpkg.com/@1stg/prettier-config/-/prettier-config-0.2.0.tgz#853c1142834f31d9287cd9e30f2b91d46e4961d6"
integrity sha512-wL0qdfsJyHQvOO0vG50StqTSIOX9kauhu6NbLHMgAXE+s3rQ4/N0slwAwYCrqHSwYRVqpeqN8EblYF6UIZiwZQ==

"@1stg/rollup-config@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@1stg/rollup-config/-/rollup-config-0.3.0.tgz#c8123192e0661ec5074d87990074c59537229a23"
integrity sha512-5uusRTvJZBivltUbXmKICPGl5FrgQoN+XPKraDpaWgpvod6RTDOvhXFzJC/uyD/zwWx7xQTHSiFBCevjNhJt8w==
dependencies:
lodash "^4.17.15"
rollup-plugin-terser "^5.1.1"
rollup-plugin-typescript "^1.0.1"
umd-globals "^0.1.0"

"@1stg/tsconfig@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@1stg/tsconfig/-/tsconfig-0.3.0.tgz#a8b3a30e518c6144e2bd7bd27edafb5ae225c04c"
Expand Down Expand Up @@ -1484,6 +1494,11 @@
resolved "https://registry.yarnpkg.com/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#1ee30d79544ca84d68d4b3cdb0af4f205663dd2d"
integrity sha512-OCutwjDZ4aFS6PB1UZ988C4YgwlBHJd6wCeQqaLdmadZ/7e+w79+hbMUFC1QXDNCmdyoRfAFdm0RypzwR+Qpag==

"@types/estree@0.0.39":
version "0.0.39"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
integrity sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==

"@types/events@*":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/events/-/events-3.0.0.tgz#2862f3f58a9a7f7c3e78d79f130dd4d71c25c2a7"
Expand Down Expand Up @@ -1545,7 +1560,7 @@
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==

"@types/node@*", "@types/node@^12.0.2":
"@types/node@*", "@types/node@^12.0.2", "@types/node@^12.7.2":
version "12.7.3"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.7.3.tgz#27b3f40addaf2f580459fdb405222685542f907a"
integrity sha512-3SiLAIBkDWDg6vFo0+5YJyHPWU9uwu40Qe+v+0MH8wRKYBimHvvAOyk3EzMrD/TrIlLYfXrqDqrg913PynrMJQ==
Expand Down Expand Up @@ -3050,6 +3065,11 @@ estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0:
resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d"
integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==

estree-walker@^0.6.1:
version "0.6.1"
resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.6.1.tgz#53049143f40c6eb918b23671d1fe3219f3a1b362"
integrity sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==

esutils@^2.0.2:
version "2.0.3"
resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64"
Expand Down Expand Up @@ -4751,7 +4771,7 @@ lodash@4.17.14:
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.14.tgz#9ce487ae66c96254fe20b599f21b6816028078ba"
integrity sha512-mmKYbW3GLuJeX+iGP+Y7Gp1AiGHGbXHCOh/jZmrawMmsE7MS4znI3RL2FsjbqOyMayHInjOeykW7PEajUk1/xw==

lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.2.1:
lodash@^4.17.11, lodash@^4.17.12, lodash@^4.17.13, lodash@^4.17.14, lodash@^4.17.15, lodash@^4.2.1:
version "4.17.15"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==
Expand Down Expand Up @@ -6124,6 +6144,41 @@ rimraf@^3.0.0:
dependencies:
glob "^7.1.3"

rollup-plugin-terser@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-5.1.1.tgz#e9d2545ec8d467f96ba99b9216d2285aad8d5b66"
integrity sha512-McIMCDEY8EU6Y839C09UopeRR56wXHGdvKKjlfiZG/GrP6wvZQ62u2ko/Xh1MNH2M9WDL+obAAHySljIZYCuPQ==
dependencies:
"@babel/code-frame" "^7.0.0"
jest-worker "^24.6.0"
rollup-pluginutils "^2.8.1"
serialize-javascript "^1.7.0"
terser "^4.1.0"

rollup-plugin-typescript@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/rollup-plugin-typescript/-/rollup-plugin-typescript-1.0.1.tgz#86565033b714c3d1f3aba510aad3dc519f7091e9"
integrity sha512-rwJDNn9jv/NsKZuyBb/h0jsclP4CJ58qbvZt2Q9zDIGILF2LtdtvCqMOL+Gq9IVq5MTrTlHZNrn8h7VjQgd8tw==
dependencies:
resolve "^1.10.0"
rollup-pluginutils "^2.5.0"

rollup-pluginutils@^2.5.0, rollup-pluginutils@^2.8.1:
version "2.8.1"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.1.tgz#8fa6dd0697344938ef26c2c09d2488ce9e33ce97"
integrity sha512-J5oAoysWar6GuZo0s+3bZ6sVZAC0pfqKz68De7ZgDi5z63jOVZn1uJL/+z1jeKHNbGII8kAyHF5q8LnxSX5lQg==
dependencies:
estree-walker "^0.6.1"

rollup@^1.20.3:
version "1.20.3"
resolved "https://registry.yarnpkg.com/rollup/-/rollup-1.20.3.tgz#6243f6c118ca05f56b2d9433112400cd834a1eb8"
integrity sha512-/OMCkY0c6E8tleeVm4vQVDz24CkVgvueK3r8zTYu2AQNpjrcaPwO9hE+pWj5LTFrvvkaxt4MYIp2zha4y0lRvg==
dependencies:
"@types/estree" "0.0.39"
"@types/node" "^12.7.2"
acorn "^7.0.0"

rsvp@^4.8.4:
version "4.8.5"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
Expand Down Expand Up @@ -6220,6 +6275,11 @@ semver@^6.0.0, semver@^6.1.0, semver@^6.1.2, semver@^6.2.0, semver@^6.3.0:
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==

serialize-javascript@^1.7.0:
version "1.9.0"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-1.9.0.tgz#5b77019d7c3b85fe91b33ae424c53dcbfb6618bd"
integrity sha512-UkGlcYMtw4d9w7YfCtJFgdRTps8N4L0A48R+SmcGL57ki1+yHwJXnalk5bjgrw+ljv6SfzjzPjhohod2qllg/Q==

set-blocking@^2.0.0, set-blocking@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7"
Expand Down Expand Up @@ -6332,7 +6392,7 @@ source-map-resolve@^0.5.0:
source-map-url "^0.4.0"
urix "^0.1.0"

source-map-support@^0.5.6:
source-map-support@^0.5.6, source-map-support@~0.5.12:
version "0.5.13"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932"
integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==
Expand Down Expand Up @@ -6626,6 +6686,15 @@ tar@^4:
safe-buffer "^5.1.2"
yallist "^3.0.3"

terser@^4.1.0:
version "4.2.1"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.2.1.tgz#1052cfe17576c66e7bc70fcc7119f22b155bdac1"
integrity sha512-cGbc5utAcX4a9+2GGVX4DsenG6v0x3glnDi5hx8816X1McEAwPlPgRtXPJzSBsbpILxZ8MQMT0KvArLuE0HP5A==
dependencies:
commander "^2.20.0"
source-map "~0.6.1"
source-map-support "~0.5.12"

test-exclude@^5.2.3:
version "5.2.3"
resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.2.3.tgz#c3d3e1e311eb7ee405e092dac10aefd09091eac0"
Expand Down Expand Up @@ -6826,6 +6895,11 @@ uglify-js@^3.1.4:
commander "~2.20.0"
source-map "~0.6.1"

umd-globals@^0.1.0:
version "0.1.2"
resolved "https://registry.yarnpkg.com/umd-globals/-/umd-globals-0.1.2.tgz#2f12119fa853b571d740610693142388739a4c00"
integrity sha512-2eoq3o9LScBgCxnukntvJAqP3axs/oTMfOCTqTSMGaM5nLXIxOtRWMcTALoTZJIC++uXqTnWbxmxw97g6w9KaA==

unherit@^1.0.4:
version "1.1.2"
resolved "https://registry.yarnpkg.com/unherit/-/unherit-1.1.2.tgz#14f1f397253ee4ec95cec167762e77df83678449"
Expand Down

0 comments on commit 93e4786

Please sign in to comment.