plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).

Home Page:http://plasma-umass.github.io/doppio-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Case sensitivity of require("browserfs")

marcosscriven opened this issue · comments

I had some issues using Webpack with Doppio, which can package modules imported with require() into a single .js file.

For some reason, the built Doppio files have require("BrowserFS"), rather than require("browserfs"), even though in the original Typescript, it's lowercase. See https://github.com/plasma-umass/doppio/blob/master/src/classpath.ts#L4 for example.

If in my own code I use all lower case, Webpack packs a second copy of BrowserFS, because it sees it as a different thing. This caused the rather confusing outcome of class files not being found, even though my own module could see them, because essentially Doppio had a separate BrowserFS instance in its scope.

I think the convention for requires is all lowercase.

Yup, NPM forbids capital letters in package names. I remember trying to publish BrowserFS as BrowserFS, and seeing an error message.

I use a Mac, so case-sensitivity issues like this occasionally creep up. Thanks for pointing out the bug!

Sorry fat fingered 'Close'

@marcosscriven I found the issue.

When I build Doppio with webpack, I specify browserfs as an external module backed by the BrowserFS global. I do this because I do not want to pack BrowserFS within Doppio.

Webpack translates this into detection code that either:

  • Fetches the global BrowserFS variable, or...
  • Tries to require("BrowserFS") if there is a module loader

I'm not sure what the correct solution is in this scenario.

@marcosscriven perhaps you should specify an external "BrowserFS" module that is backed by a "BrowserFS" variable like I did? Then you wouldn't bundle BrowserFS, and it would resolve properly to a global?

Thanks for looking into it @jvilk - I'll give that a go at the weekend.

I think I found a solution!

https://stackoverflow.com/questions/34252424/webpack-umd-lib-and-external-files

Going to try this out next.