-
Notifications
You must be signed in to change notification settings - Fork 90
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
Error: Can't find variable VARIABLE_NAME #93
Error: Can't find variable VARIABLE_NAME #93
Comments
@samouss Good point. I was not aware that exported functions are not inside of a closure. Are you using any other plugins beside the rewire plugin? |
I'm using it with I transpiles my files without him and the variables are available. Is there any possibility to support this format ? |
@samouss I have to look deeper into it, but i am planning to support it. |
@samouss could you possibly change the order in which you apply your plugins (babel-plugin-rewire first)? |
I tried, but it's doesn't do anything. |
I'm having a similar issue. I'm exporting named functions as well as a default export. What I see is that in the transpiled version the exports property is set to the function variable before that variable is defined. // reducePropsToState is not yet defined, so exports.reducePropsToState is `undefined`
exports.reducePropsToState = reducePropsToState;
// a little further down, reducePropsToState id defined
var reducePropsToState = _reducePropsToStateOrig;
// at this point reducePropsToState and _reducePropsToStateOrig are defined
// exports.reducePropsToState, however is not. My src looks something like this: export function reducePropsToState(propsList) {
...
}
export default withSideEffect(
reducePropsToState,
handleStateChangeOnClient,
mapStateOnServer
)(Meta); |
Relevant items from package.json {
"babel": "^5.8.21",
"babel-core": "^5.8.22",
"babel-eslint": "^4.1.6",
"babel-loader": "^5.4.0",
"babel-plugin-object-assign": "^1.2.1",
"babel-plugin-react-transform": "^1.1.1",
"babel-plugin-rewire": "^0.1.22",
"webpack": "^1.12.2"
} |
sorry for the delay, but I have to ship the babel 6 api before. So it will take some more time till we get the System.js issues. But it won't be forgotten. |
Seems like this may have actually been forgotten? |
I've found that if I use webpack + babel + babel-plugin-rewire and I import a module it fails with For example, this works: const assert = require('assert') Where as this fails: import assert from 'assert' |
@speedskater here is a sample repo that shows the issue: |
@danawoodman Thank your for bringing this issue up again. sorry for the delayed answer but I have been on holidays over the last 3 weeks. tomorrow in the evening I think I will find some time to have a look at your example. I will then let you know how we can proceed with this issue. |
Thanks @speedskater! Really love this module and am sad I can't use it 😄 |
@danawoodman i just reviewed your project and it seems that the problem is a conflicting configuration between the webpack config file and the .babelrc file. I created a PR for your sample project containing the fix. |
Thanks @speedskater ! |
Hi,
I try to setup my test workflow with
babel-plugin-rewire
but I'm encounter some trouble.I'm using it in Karma and I use the version
1.0.0-beta-5
.I have the following module:
Which will be transpile to (I cut the file for the example):
Okay, so when the function
_get__
will be called with value'getDisplay'
, it'll check if an override exist, if it does, it return the override. If the override doesn't exist it return the original value which in my case is functiongetDisplay
.But the function
getDisplay
is not available when we make the switch in_get__original__,
thus an error is throw.I see in other files, that you moves unexported functions at the top of the file.
Why don't do it with exported functions too ?
The text was updated successfully, but these errors were encountered: