FlorianRappl / parcel-plugin-externals

Parcel plugin for declaring externals. These externals will not be bundled. :package:
https://piral.io
MIT License
47 stars 3 forks source link

Exception on browser property set to false #6

Closed jfrconley closed 4 years ago

jfrconley commented 5 years ago

The package.json browser field allows properties to be set to false to exclude files from bundling. However, this causes parcel-plugin-externals to crash as resolve does not accept values other than strings.

FlorianRappl commented 5 years ago

Hi @jfrconley can you provide a MWE such that I can fully understand / fix the problem? Many thanks :beers:!

jfrconley commented 5 years ago

The easiest way to reproduce is marking aws-sdk as a peer dependency

{
    "name": "external-issue",
    "version": "1.0.0",
    "main": "index.js",
    "scripts": {
        "parcel": "parcel build -t node --bundle-node-modules --detailed-report --no-source-maps -d bundle src/index.ts"
    },
    "license": "MIT",
    "dependencies": {
        "aws-sdk": "^2.561.0"
    },
    "devDependencies": {
        "parcel-bundler": "^1.12.4",
        "parcel-plugin-externals": "^0.2.0"
    },
    "peerDependency": {
        "aws-sdk": "*"
    }
}

This will cause resolution to fail and parcel-plugin-external to output "module not found".

Relevant snippet from aws-sdk package.json

  "browser": {
    "lib/aws.js": "./lib/browser.js",
    "fs": false, <- Causes failure
    "./global.js": "./browser.js",
    "./lib/node_loader.js": "./lib/browser_loader.js"
  },
FlorianRappl commented 5 years ago

Nevermind my previous comment; in your example it was peerDependency instead of peerDependencies.

Behavior found. Fix on the way!

FlorianRappl commented 5 years ago

Landed in develop. Please check the 0.3 preview version to see if its fixed! Thanks!

jfrconley commented 4 years ago

Issue seems to be resolved. Thank you much!