Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Commented-out require() is not ignored #1

Open
richardassar opened this Issue · 3 comments

2 participants

@richardassar

When commenting out a require the file is still pulled into the bundle.

@richardassar

I think it might require stripping all comments from source before processing.

For example

/* This block comment could cause problems
var example = require("example");
*/

// As can single-line comments
// var example = require("example");

I had a look and comment removal is not as trivial as it might seem.

A naive approach might call for source.replace(/\/\*[\w\W]*\*\//g, '') to remove block comments, but this will fail when the block comment includes a regex with "*/" or "/*" inside. These cases might slightly rare, but not rare enough to ignore.

After a very quick google, this link seems to provide useful info on the subject.

Btw, really like this project. It is good to have some more options out there to Ender and Browserify.

@jgallen23
Owner

Thanks for the info. I'm going to look into this: http://esprima.org/ might be a better way to parse out the javascript rather than using regex.

@richardassar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.