Skip to content

Instantly share code, notes, and snippets.

@RA80533
Created November 12, 2020 20:36
Show Gist options
  • Save RA80533/d174dd927c7e39a4d2a40ea9fb2e4519 to your computer and use it in GitHub Desktop.
Save RA80533/d174dd927c7e39a4d2a40ea9fb2e4519 to your computer and use it in GitHub Desktop.
Patch for parcel-bundler which fixes several outstanding issues
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) {
@RA80533
Copy link
Author

RA80533 commented Nov 12, 2020

Patch for parcel-bundler which fixes several outstanding issues

$ git apply -p2 --directory="node_modules" --unsafe-paths "parcel-bundler+1.12.4.patch"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment