Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving --no-browser-globals #29

Closed
mattdesl opened this issue Jan 26, 2016 · 9 comments
Closed

Improving --no-browser-globals #29

mattdesl opened this issue Jan 26, 2016 · 9 comments
Labels

Comments

@mattdesl
Copy link
Contributor

Since #23 I have added --no-browser-globals which was a first attempt at solving some issues with node modules that rely on window / document / etc (i.e. doing some node-type code if window is undefined).

This causes some new issues in some cases:
https://twitter.com/yaypie/status/692127048773550080

The problem is basically here:
https://github.com/zloirock/core-js/blob/270fabccd38e0210caf1a4ffc44ca328880fba69/modules/_global.js

console.log(Function('return this')())

Where this in that context evaluates to window...

@rgrove
Copy link

rgrove commented Jan 26, 2016

One more --no-browser-globals issue from my app: my entry point script has a shebang as its first line, which causes additional confusion:

160126hr0og

Thanks for reaching out and offering to help, btw! Devtool looks super promising.

@mattdesl
Copy link
Contributor Author

@rgrove I can't seem to reproduce the shebang parse error. Can you add any details here? #30

@mattdesl mattdesl added the bug label Jan 27, 2016
@mattdesl
Copy link
Contributor Author

@rgrove
I've made some fixes to the following:

  • Fixing the misleading syntax error reporting upstream (waiting on the PR to be merged)
  • Fixing an issue with Bluebird when using --no-bg (which is part of the second issue you reported)
  • Fixing the original issue in this thread which was caused by self which should be undefined in Node

Can you test again with devtool@1.7.1?

@rgrove
Copy link

rgrove commented Jan 27, 2016

@mattdesl 1.7.1 gets further, and the shebang parse error is gone now! Still getting lots of SyntaxError: Unexpected end of input errors though, and after a bunch of these my app finally crashes since it can't properly initialize itself.

When I look at the files that are causing the errors, the one thing that stands out is that none of them end with a newline. I added an ending newline to one of them and, sure enough, the SyntaxError disappeared.

Here's the latest console output, in case it helps:

Error compiling module: /Users/rgrove/src/cake/www/node_modules/core-js/library/modules/$.global.js
Unexpected end of input
SyntaxError: Unexpected end of input
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/core-js/library/modules/$.export.js:1:131)
    at Module._compile (module.js:425:26)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/core-js/library/modules/$.iter-define.js:3:22)
    at Module._compile (module.js:425:26)
Error compiling module: /Users/rgrove/src/cake/www/node_modules/core-js/library/modules/$.core.js
Unexpected end of input
SyntaxError: Unexpected end of input
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/core-js/library/modules/$.export.js:2:17)
    at Module._compile (module.js:425:26)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/core-js/library/modules/$.iter-define.js:3:22)
    at Module._compile (module.js:425:26)
Error compiling module: /Users/rgrove/src/cake/www/node_modules/babel-core/node_modules/babel-traverse/lib/path/constants.js
Unexpected end of input
SyntaxError: Unexpected end of input
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/babel-core/node_modules/babel-traverse/lib/path/index.js:21:18)
    at Module._compile (module.js:425:26)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/babel-core/node_modules/babel-traverse/lib/context.js:13:13)
    at Module._compile (module.js:425:26)
Error compiling module: /Users/rgrove/src/cake/www/node_modules/babel-traverse/lib/path/constants.js
Unexpected end of input
SyntaxError: Unexpected end of input
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/babel-traverse/lib/path/index.js:21:18)
    at Module._compile (module.js:425:26)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/babel-traverse/lib/context.js:13:13)
    at Module._compile (module.js:425:26)
Error compiling module: /Users/rgrove/src/cake/www/node_modules/babylon/lib/tokenizer/state.js
Unexpected end of input
SyntaxError: Unexpected end of input
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/babylon/lib/tokenizer/index.js:19:14)
    at Module._compile (module.js:425:26)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/babylon/lib/parser/index.js:19:18)
    at Module._compile (module.js:425:26)
Error compiling module: /Users/rgrove/src/cake/www/node_modules/babel-generator/node_modules/babel-traverse/lib/path/constants.js
Unexpected end of input
SyntaxError: Unexpected end of input
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/babel-generator/node_modules/babel-traverse/lib/path/index.js:21:18)
    at Module._compile (module.js:425:26)
    at Object.devtoolCompileModule [as .js] (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object.<anonymous> (/Users/rgrove/src/cake/www/node_modules/babel-generator/node_modules/babel-traverse/lib/context.js:13:13)
    at Module._compile (module.js:425:26)
Error compiling module: /Users/rgrove/src/cake/www/node_modules/babel-helper-builder-react-jsx/lib/index.js
Unexpected end of input
SyntaxError: Unexpected end of input
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:404:25)
    at devtoolCompileModule (/usr/local/lib/node_modules/devtool/lib/require-hook.js:37:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/rgrove/src/cake/www/node_modules/babel-register/lib/node.js:138:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at exports.default (/Users/rgrove/src/cake/www/node_modules/babel-plugin-transform-react-jsx/lib/index.js:12:17)
    at Function.memoisePluginContainer (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:127:13)
    at Function.normalisePlugin (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:161:32)
    at /Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:197:30
    at Array.map (native)
    at Function.normalisePlugins (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:173:20)
    at OptionManager.mergeOptions (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:271:36)
    at OptionManager.mergePresets (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:325:16)
TypeError: require(...) is not a function
    at exports.default (/Users/rgrove/src/cake/www/node_modules/babel-plugin-transform-react-jsx/lib/index.js:12:58)
    at Function.memoisePluginContainer (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:127:13)
    at Function.normalisePlugin (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:161:32)
    at /Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:197:30
    at Array.map (native)
    at Function.normalisePlugins (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:173:20)
    at OptionManager.mergeOptions (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:271:36)
    at OptionManager.mergePresets (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:325:16)
    at OptionManager.mergeOptions (/Users/rgrove/src/cake/www/node_modules/babel-core/lib/transformation/file/options/option-manager.js:287:12)
    at compile (/Users/rgrove/src/cake/www/node_modules/babel-register/lib/node.js:85:15)
    at loader (/Users/rgrove/src/cake/www/node_modules/babel-register/lib/node.js:130:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/rgrove/src/cake/www/node_modules/babel-register/lib/node.js:140:7)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:313:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)

@mattdesl
Copy link
Contributor Author

Ok, I managed to get this universal webpack boilerplate running/debugging inside devtool with a few more tweaks (see 1.7.2). I think we will have to keep testing on real-world apps to track down any more problems.

I will probably need some isolated test to fix the above bugs since it isn't clear where the problem is.

Thanks again!

@mattdesl
Copy link
Contributor Author

Update: the "Unexpected end of input" was just a silly typo on the way I was wrapping modules in a closure (forgot a new line). So at least now that bug is fixed in 1.7.3.

@rgrove
Copy link

rgrove commented Jan 27, 2016

Hooray! As of 1.7.3, devtool runs my app perfectly. Thanks for all the help, @mattdesl!

@mattdesl
Copy link
Contributor Author

Awesome! I am going to close this. I'm sure something else will come up eventually, feel free to post a new issue when/if it breaks. 😄

@bsr203
Copy link

bsr203 commented Feb 3, 2016

hi @mattdesl I have react/webpack project, and use tape for testing. Testing works great with tape, but sometimes I really needed devtool to trace error. Do you think it is possible to use it with above stack. An example with any of the react boiler plates out there would be awesome. thanks a ton for your help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants