Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-in modules from node_modules don't register and includeNodeModules not working #7329

Closed
joshuali7536 opened this issue Nov 19, 2021 · 0 comments · Fixed by #7348
Closed

Comments

@joshuali7536
Copy link

🐛 bug report

I am currently trying to migrate from Parcel 1 to Parcel 2 for a project I am working on. However, it doesn't seem to register any built-in node_modules as an internal dependency, such as path, buffer, url, or process. I have also added the targets to includeNodeModules as recommended here, but that still results in the same errors.

🎛 Configuration (.babelrc, package.json, cli command)

package.json

{
  "name": "filer",
  "description": "Node-like file system for browsers",
  "keywords": [
    "fs",
    "node",
    "file",
    "filesystem",
    "browser",
    "indexeddb",
    "idb"
  ],
  "version": "1.4.1",
  "author": "Alan K <[email protected]> (http://blog.modeswitch.org)",
  "homepage": "http://filerjs.github.io/filer",
  "bugs": "https://github.com/filerjs/filer/issues",
  "license": "BSD-2-Clause",
  "filerjs": "filer.js",
  "filerminjs": "filer.min.js",
  "scripts": {
    "eslint": "npm run lint",
    "eslint:fix": "npm run lint:fix",
    "lint": "eslint src tests",
    "lint:fix": "eslint --fix src tests",
    "test:node": "mocha --timeout 5000 tests",
    "pretest:node-debug": "echo \"Open Chrome to chrome://inspect to debug tests...\"",
    "test:node-debug": "mocha --timeout 5000 --inspect-brk tests",
    "test:manual": "parcel tests/index.html --dist-dir tests/dist",
    "test:migrations": "mocha tests/filesystems/migrations",
    "pretest": "npm run lint",
    "test": "npm run karma-mocha",
    "posttest": "npm run test:migrations",
    "prebuild": "parcel build --global Filer src/index.js --no-minify filerjs",
    "build": "parcel build --global Filer src/index.js filerminjs --detailed-report",
    "build-tests": "parcel build tests/index.js --no-source-maps --dist-dir tests/dist",
    "prekarma-mocha-firefox": "npm run build-tests",
    "karma-mocha-firefox": "karma start karma.conf.js --browsers FirefoxHeadless",
    "prekarma-mocha-chrome": "npm run build-tests",
    "karma-mocha-chrome": "karma start karma.conf.js --browsers ChromeHeadless",
    "prekarma-mocha": "npm run build-tests",
    "karma-mocha": "karma start karma.conf.js --browsers ChromeHeadless,FirefoxHeadless",
    "coverage": "nyc mocha tests/index.js",
    "release": "run.env release-it"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/filerjs/filer.git"
  },
  "dependencies": {
    "chai": "^4.3.4",
    "chai-datetime": "^1.8.0",
    "es6-promisify": "^7.0.0",
    "fake-indexeddb": "^3.1.7",
    "minimatch": "^3.0.4",
    "schema-utils": "^3.1.1",
  },
  "devDependencies": {
    "regenerator-runtime": "^0.13.9",
    "chai": "^4.3.4",
    "chai-datetime": "^1.8.0",
    "eslint": "^7.32.0",
    "fake-indexeddb": "^3.1.7",
    "karma": "^6.3.8",
    "karma-chai": "^0.1.0",
    "karma-chrome-launcher": "^3.1.0",
    "karma-firefox-launcher": "^2.1.2",
    "karma-mocha": "^2.0.1",
    "karma-mocha-reporter": "^2.2.5",
    "karma-summary-reporter": "^3.0.0",
    "meow": "^10.0.1",
    "mocha": "^9.1.3",
    "nyc": "^15.1.0",
    "parcel": "^2.0.1",
    "pretty-bytes": "^5.6.0",
    "release-it": "^14.11.6",
    "run.env": "^1.1.0",
    "unused-filename": "^3.0.1",
    "walk": "^2.3.15"
  },
  "targets": {
    "default": {
      "includeNodeModules": true
    }
  },
  "browser": "./dist/filer.min.js",
  "files": [
    "src",
    "lib",
    "dist",
    "shims",
    "webpack"
  ],
  "nyc": {
    "exclude": [
      "tests/**/*.js",
      "lib/**/*.js",
      "src/providers/**/*.js"
    ],
    "reporter": [
      "lcov",
      "text"
    ]
  }
}

🤔 Expected Behavior

When we used the previous version of parcel it did not give any errors with built-in modules from node_modules. We did not have to include them as external dependencies.

😯 Current Behavior

Currently we get the following error for buffer, path, process, and url respectively. When we require() it doesn't recognize the modules as part of the internal node_modules.

$ npm test
Building...
× Build failed.

@parcel/core: Failed to resolve 'path' from './src/path.js'

  C:\Users\Joshua\Documents\GitHub\filer\src\path.js:12:26
    11 |  */
  > 12 | const nodePath = require('path');
  >    |                          ^^^^^^
    13 | const filerPath = Object.assign({}, nodePath);
    14 |

@parcel/resolver-default: External dependency "path" is not declared in package.json.

  C:\Users\Joshua\Documents\GitHub\filer\package.json:49:3
    48 |   },
  > 49 |   "dependencies": {
  >    |   ^^^^^^^^^^^^^^
    50 |     "buffer": "^6.0.3",
    51 |     "chai": "^4.3.4",

  ℹ Add "path" as a dependency.

💁 Possible Solution

🔦 Context

💻 Code Sample

This is the branch I am currently working on: https://github.com/joshuali7536/filer/tree/issue-794

🌍 Your Environment

Software Version(s)
Parcel 2.0.1
Node 14.18.0
npm/Yarn 6.14.5
Operating System Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant