Created
November 12, 2020 20:36
-
-
Save RA80533/d174dd927c7e39a4d2a40ea9fb2e4519 to your computer and use it in GitHub Desktop.
Patch for parcel-bundler which fixes several outstanding issues
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
diff --git a/node_modules/parcel-bundler/src/Resolver.js b/node_modules/parcel-bundler/src/Resolver.js | |
index 825e45d..471cd26 100755 | |
--- a/node_modules/parcel-bundler/src/Resolver.js | |
+++ b/node_modules/parcel-bundler/src/Resolver.js | |
@@ -175,6 +175,10 @@ class Resolver { | |
let parts = getModuleParts(filename); | |
let root = path.parse(dir).root; | |
+ if (parts[0] === 'core-js') { | |
+ dir = path.resolve(require.main.children[0].path, '../..'); | |
+ } | |
+ | |
while (dir !== root) { | |
// Skip node_modules directories | |
if (path.basename(dir) === 'node_modules') { | |
diff --git a/node_modules/parcel-bundler/src/transforms/babel/env.js b/node_modules/parcel-bundler/src/transforms/babel/env.js | |
index 5dee001..c30b10c 100644 | |
--- a/node_modules/parcel-bundler/src/transforms/babel/env.js | |
+++ b/node_modules/parcel-bundler/src/transforms/babel/env.js | |
@@ -51,12 +51,12 @@ async function getEnvPlugins(targets, useBuiltIns = false) { | |
const options = { | |
targets, | |
modules: false, | |
- useBuiltIns: useBuiltIns ? 'entry' : false, | |
+ useBuiltIns: useBuiltIns ? 'usage' : false, | |
shippedProposals: true | |
}; | |
if (useBuiltIns) { | |
- options.corejs = 2; | |
+ options.corejs = '3.6'; | |
} | |
let plugins = presetEnv.default({assertVersion: () => true}, options).plugins; | |
diff --git a/node_modules/parcel-bundler/src/utils/getTargetEngines.js b/node_modules/parcel-bundler/src/utils/getTargetEngines.js | |
index 0571b28..c1febb3 100644 | |
--- a/node_modules/parcel-bundler/src/utils/getTargetEngines.js | |
+++ b/node_modules/parcel-bundler/src/utils/getTargetEngines.js | |
@@ -25,7 +25,7 @@ async function getTargetEngines(asset, isTargetApp) { | |
let engines = pkg && pkg.engines; | |
let nodeVersion = engines && getMinSemver(engines.node); | |
- if (compileTarget === 'node') { | |
+ if (compileTarget === 'node' && nodeVersion !== undefined) { | |
// Use package.engines.node by default if we are compiling for node. | |
if (typeof nodeVersion === 'string') { | |
targets.node = nodeVersion; | |
@@ -39,9 +39,13 @@ async function getTargetEngines(asset, isTargetApp) { | |
} else if (pkg && pkg.browserslist) { | |
targets.browsers = pkg.browserslist; | |
} else { | |
- let browserslist = await loadBrowserslist(asset, path); | |
- if (browserslist) { | |
- targets.browsers = browserslist; | |
+ let browserslistrc = await loadBrowserslist(asset, path); | |
+ if (browserslistrc) { | |
+ if (compileTarget === 'node') { | |
+ targets.node = browserslist(browserslistrc.defaults)[0].split(/\s/)[1]; | |
+ } else { | |
+ targets.browsers = browserslistrc; | |
+ } | |
} else { | |
let babelTargets = await loadBabelrc(asset, path); | |
if (babelTargets && babelTargets.browsers) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ git apply -p2 --directory="node_modules" --unsafe-paths "parcel-bundler+1.12.4.patch"