Skip to content

Commit

Permalink
make life easier
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Feb 9, 2021
1 parent 9eb131b commit cea9f58
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function bool(value) {
// semverGte("8.9", "8.9") // true
// semverGte("9.0", "8.9") // true
// semverGte("8.9", "8.10") // false
const semverGte = `((a,b)=>(([,v,x,w,y]=/(\\d+)\\.(\\d+).*,(\\d+)\\.(\\d+)/.exec([a,b])),+v>+w||v==w&&+x>=+y))`;
`((a,b)=>(([,v,x,w,y]=/(\\d+)\\.(\\d+).*,(\\d+)\\.(\\d+)/.exec([a,b])),+v>+w||v==w&&+x>=+y))`;

// TODO(Babel 8) This polyfills are only needed for Node.js 6 and 8
/** @param {import("@babel/core")} api */
Expand All @@ -220,7 +220,7 @@ function pluginPolyfillsOldNode({ template, types: t }) {
// require.resolve's paths option has been introduced in Node.js 8.9
// https://nodejs.org/api/modules.html#modules_require_resolve_request_options
replacement: template({ syntacticPlaceholders: true })`
${semverGte}(process.versions.node, "8.9")
((a,b)=>(([,v,x,w,y]=/(\\d+)\\.(\\d+).*,(\\d+)\\.(\\d+)/.exec([a,b])),+v>+w||v==w&&+x>=+y))(process.versions.node, "8.9")
? require.resolve
: (/* request */ r, { paths: [/* base */ b] }, M = require("module")) => {
let /* filename */ f = M._findPath(r, M._nodeModulePaths(b).concat(b));
Expand Down Expand Up @@ -252,7 +252,7 @@ function pluginPolyfillsOldNode({ template, types: t }) {
// fs.mkdirSync's recursive option has been introduced in Node.js 10.12
// https://nodejs.org/api/fs.html#fs_fs_mkdirsync_path_options
replacement: template`
${semverGte}(process.versions.node, "10.12")
((a,b)=>(([,v,x,w,y]=/(\\d+)\\.(\\d+).*,(\\d+)\\.(\\d+)/.exec([a,b])),+v>+w||v==w&&+x>=+y))(process.versions.node, "10.12")
? fs.mkdirSync
: require("make-dir").sync
`,
Expand Down

0 comments on commit cea9f58

Please sign in to comment.