Skip to content
This repository has been archived by the owner on May 26, 2022. It is now read-only.

Incorrectly finds goog.require and goog.provide statements in comments #16

Open
tlrobinson opened this issue May 11, 2016 · 5 comments
Open

Comments

@tlrobinson
Copy link

The simple regex approach incorrectly finds goog.require and goog.provides statements that are within JavaScript comments, which can break compilation in certain situations.

@eXaminator
Copy link
Collaborator

Hi, thanks for the info and good point. I'll have to think about this a while. Any suggestions. I could try parsing files with babylon or acorn or something similar, but I guess that would be slower and might fail on files that contain syntax errors. Also I don't know anything about JS parsers yet so it would probably take a lot of time I don't have right now.

I will leave this open for now and might come back to it later. But PRs are welcome.

@jdb8
Copy link

jdb8 commented May 19, 2016

Something I did during my experiments to get the loader working for 'goog:foo.bar.baz' style imports (#12) was to enforce start-of-line in the regex, and add the multiline flag: jdb8@3408c00

I'm going to go clean this up (since this probably still misses some stuff, and the /g flag might not be necessary), but this seems robust enough at least for my needs.

@giuseppeg
Copy link

You could strip out the comments at matching time.
Here's how facebook does it https://github.com/facebook/node-haste/blob/master/src/lib/extractRequires.js

@lexoyo
Copy link

lexoyo commented Mar 23, 2019

hello
@jdb8 it's a good fix, why not make a PR?

@lexoyo
Copy link

lexoyo commented Mar 23, 2019

says a guy 3 years later 😢

lexoyo added a commit to lexoyo/closure-loader that referenced this issue Mar 23, 2019
This is a workaround for the issue mxmul#16  "Incorrectly finds `goog.require` and `goog.provide` statements in comments"
lexoyo added a commit to lexoyo/closure-loader that referenced this issue Mar 23, 2019
This is a workaround for the issue mxmul#16  "Incorrectly finds `goog.require` and `goog.provide` statements in comments"
lexoyo added a commit to lexoyo/closure-loader that referenced this issue Mar 23, 2019
This is a workaround for the issue mxmul#16  "Incorrectly finds `goog.require` and `goog.provide` statements in comments"
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants