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

injectGlobal #196

Closed
Geczy opened this issue Jul 28, 2017 · 1 comment
Closed

injectGlobal #196

Geczy opened this issue Jul 28, 2017 · 1 comment

Comments

@Geczy
Copy link

Geczy commented Jul 28, 2017

  • emotion version: 6.0.3
  • react version: 15.6.1

Relevant code.

import { injectGlobal } from 'emotion'

injectGlobal`
  ...
`

What happened:

ERROR in ./src/components/App.js                
Module build failed: SyntaxError: C:/Users/Matt/Documents/GitHub/frontend/src/components/App.js: NodePath has been removed so is read-only. (This is an error on an internal node. Probably an internal error)
    at File.buildCodeFrameError (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-core\lib\transformation\file\index.js:427:15)
    at NodePath.buildCodeFrameError (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\path\index.js:140:26)
    at NodePath._assertUnremoved (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\path\removal.js:70:16)
    at NodePath.remove (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\path\removal.js:20:8)
    at replaceGlobalWithCallExpression (C:\Users\Matt\Documents\GitHub\frontend\node_modules\emotion\lib\babel.js:264:23)
    at PluginPass.TaggedTemplateExpression (C:\Users\Matt\Documents\GitHub\frontend\node_modules\emotion\lib\babel.js:91:13)
    at newFn (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\visitors.js:276:21)
    at NodePath._call (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\path\context.js:76:18)
    at NodePath.call (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\path\context.js:48:17)
    at NodePath.visit (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\path\context.js:105:12)
    at TraversalContext.visitQueue (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\context.js:150:16)
    at TraversalContext.visitSingle (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\context.js:108:19)
    at TraversalContext.visit (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\context.js:192:19)
    at Function.traverse.node (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\index.js:114:17)
    at NodePath.visit (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\path\context.js:115:19)
    at TraversalContext.visitQueue (C:\Users\Matt\Documents\GitHub\frontend\node_modules\babel-traverse\lib\context.js:150:16)
 @ ./src/index.js 31:11-36 56:2-59:4 57:4-29

Suggested solution:
Assign injectGlobal to const

#186 (comment)

@emmatown
Copy link
Member

emmatown commented Jul 28, 2017

This is caused by these lines. The stuff inside the if block can be removed and the whole block can be replaced with the contents of the else block(path.replaceWith(t.identifier('undefined')))

The optimisation I was trying to with that if isn't needed since uglify will remove the undefined expression anyway.

@Geczy if you or anyone else wants to do this that would be great.

bogas04 added a commit to bogas04/emotion that referenced this issue Jul 31, 2017
As per @mitchellhamilton's suggestion, removing this part should be good enough.
@thangngoc89 thangngoc89 mentioned this issue Jul 31, 2017
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants