Giter VIP home page Giter VIP logo

Comments (2)

ljharb avatar ljharb commented on May 28, 2024

If something works with npm, and not with an alternative package manager, then it seems likely to be a bug in that package manager. If pnpm, or yarn, or anyone else is placing things in a different location than npm does, then it's responsible for also ensuring that standard module resolution APIs act as if things are in an npm-installed location.

Have you filed an issue on pnpm to investigate? If there's something in browserify then a fix ofc can be investigated, but it seems worth checking with pnpm first.

from browserify.

wmartins avatar wmartins commented on May 28, 2024

Hi @ljharb, thanks for mentioning it! About opening it on pnpm, from what I read yesterday, when an issue is tooling related, it's something that pnpm wont solve, according to this:

pnpm/pnpm#801

Also, we had a similar issue in the past which was open there and solved in browserify/module-deps:

pnpm/pnpm#795
browserify/module-deps#133

I ended up deciding to open it here because I saw an issue that involved the same package (is-buffer), which was solved in browserify/insert-module-globals:

#1825.
browserify/insert-module-globals#75.

Also, since it has something to do with patching Buffer.isBuffer (which seems to be browserify's responsibility) I thought this would be the right place.

One more thing to add, if I change the call in browserify/insert-module-globals from path.relative to path.resolve, it ends up bundling things correctly:

diff --git a/index.js b/index.js
index dfc2664..3c35f03 100644
--- a/index.js
+++ b/index.js
@@ -10,7 +10,7 @@ var isbufferPath = require.resolve('is-buffer')
 var combineSourceMap = require('combine-source-map');
 
 function getRelativeRequirePath(fullPath, fromPath) {
-  var relpath = path.relative(path.dirname(fromPath), fullPath);
+  var relpath = path.resolve(path.dirname(fromPath), fullPath);
   // If fullPath is in the same directory or a subdirectory of fromPath,
   // relpath will result in something like "index.js", "src/abc.js".
   // require() needs "./" prepended to these paths.

However, there's one test that ends up failing because of this: https://github.com/browserify/insert-module-globals/blob/0549e4372523ec2c967058b0bfce51fad9038b0f/test/isbuffer.js#L22.

from browserify.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.