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

feat: export header and Babel preset #5

Merged
merged 1 commit into from
Dec 30, 2019
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
17 changes: 2 additions & 15 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
{
"presets": [
[
"@babel/preset-env",
{
"targets": "maintained node versions",
"useBuiltIns": "usage",
"corejs": 3
}
],
"@babel/preset-typescript"
],
"plugins": [
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread"
]
"exclude": ["**/node_modules/**"],
"presets": [["./babel-preset", { "ts": true }]]
}
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
!/.eslintrc
/bin
/declarations
/dist
/lib
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@

# built files
/bin
/declarations
/dist
/vis-dev-util-0.0.0-no-version.tgz
/lib
/vis-dev-utils-0.0.0-no-version.tgz
75 changes: 75 additions & 0 deletions babel-preset/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
module.exports = function(_context, { css = false, ts = false } = {}) {
const base = {
presets: [
[
require("@babel/preset-env"),
{
targets: {
// A browser is polyfilled if it is supported by it's maintainers
// or if it is used by at least one in every thousand of users.
browsers: "> 0.1% or not dead",
// This forces Babel to polyfill ESM as if it was UMD. The reason
// behind this is that that Babel doesn't include IE 11 polyfills
// in ESM builds since IE 11 can't even load them. However many of
// our users use bundlers to bundle ESM builds into IE 11
// compatible UMD builds. Therefore even ESM builds need IE 11
// polyfills.
esmodules: false
},
// This would pollute global scope. Babel's Transform Runtime plugin
// is used instead.
useBuiltIns: false
}
]
],
plugins: [
require("@babel/plugin-proposal-class-properties"),
require("@babel/plugin-proposal-object-rest-spread"),
[
require("@babel/plugin-transform-runtime"),
{
// Force corejs 3. The default corejs 2 is deprecated and doesn't
// contain some polyfills.
corejs: 3
}
]
],
env: {
test: {
presets: [
[
require("@babel/preset-env"),
{
// Tests run in Node so there's no need to include any other
// polyfills (we're testing our code, not the polyfills).
targets: "maintained node versions"
}
]
]
},
"test-cov": {
presets: [
[
require("@babel/preset-env"),
{
// dtto
targets: "maintained node versions"
}
]
],
// This instruments the code to record coverage. It's more reliable if
// done through Babel plugin.
plugins: ["istanbul"]
}
}
};

if (css) {
base.plugins.push(require("babel-plugin-css-modules-transform"));
}
if (ts) {
base.presets.push(require("@babel/preset-typescript"));
}

return base;
};
44 changes: 0 additions & 44 deletions lib/header.js

This file was deleted.

Loading