plasma-umass / doppio

Breaks the browser language barrier (includes a plugin-free JVM).
http://plasma-umass.github.io/doppio-demo
MIT License
2.16k stars 174 forks source link

Case sensitivity of require("browserfs") #475

Closed marcosscriven closed 7 years ago

marcosscriven commented 7 years ago

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.

jvilk commented 7 years ago

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!

marcosscriven commented 7 years ago

Sorry fat fingered 'Close'

jvilk commented 7 years ago

@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:

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

jvilk commented 7 years ago

@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?

marcosscriven commented 7 years ago

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

jvilk commented 7 years ago

I think I found a solution!

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

Going to try this out next.