-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: export header and Babel preset (#5)
These two things are almost identical across our projects already and it makes a lot of sense to have them shared from a single source. Babel preset (TypeScript and CSS are optional): ```json { "exclude": ["**/node_modules/**"], "presets": [["vis-dev-utils/babel-preset", { "css": true, "ts": true }]] } ``` Header (reads package.json): ```javascript import { generateHeader } from "vis-dev-utils"; const banner = generateHeader(); ``` custom values can be supplied if necessary (tsdoc included): ```javascript const banner = generateHeader({ name: 'vis-timeline and vis-graph2d' }); ```
- Loading branch information
Showing
13 changed files
with
1,151 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }]] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
!/.eslintrc | ||
/bin | ||
/declarations | ||
/dist | ||
/lib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.