browserify / static-module

convert module usage to inline expressions
MIT License
74 stars 23 forks source link

Add support for bracket notation #11

Closed devongovett closed 8 years ago

devongovett commented 9 years ago

This adds support for statically analyzable bracket notation (currently just literals). Makes this work:

var fs = require("fs");
fs["readFileSync"]("filename.bin");

and this:

var read = require("fs")["readFileSync"];
read("filename.bin");

This notation is often used by programs that are subject to minification where variable names/properties are mangled. For example, emscripten generates code like this, which is where I saw the error that happens currently.

mattdesl commented 8 years ago

Thanks for this. :+1:

I've been added as a contributor to this so there should be more improvements coming soon.

mattdesl commented 8 years ago

P.S. Would you be interested in helping maintain this module? It would be good if substack could add a couple more contributors who are familiar with the source and AST manipulations.