-
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
Compatibility fixes for Babel 7 #211
Conversation
import { wasProcessed, noRewire } from './RewireHelpers.js'; | ||
import * as t from 'babel-types'; | ||
var t; | ||
var universalAccesorsTemplate; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use scope these variables to the RewireState
class with this.<variable>
, similar to this.isES6Module
and the others? Also we should probably prefer const
or let
to var
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ran into issues with this.t
, because of a few places it is referenced from unbound functions. Also it was a larger change. This way we just inject the lib at the top level when we get it from babel invoking us.
src/RewireState.js
Outdated
@@ -126,6 +134,8 @@ export default class RewireState { | |||
UNIVERSAL_RESETTER_ID :this.getUniversalResetterID(), | |||
UNIVERSAL_WITH_ID :this.getUniversalWithID(), | |||
API_OBJECT_ID: this.getAPIObjectID(), | |||
INTENTIONAL_UNDEFINED: t.identifier('INTENTIONAL_UNDEFINED'), | |||
__INTENTIONAL_UNDEFINED__: '__INTENTIONAL_UNDEFINED__', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this one used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
babel 7's template is more picky about strings that look like placeholders but are not filled in. This was the simplest way to fix it without changing the generated code.
src/Templates.js
Outdated
if (REWIRED_DATA_IDENTIFIER === undefined || REWIRED_DATA_IDENTIFIER[variableName] === undefined) { | ||
return ORIGINAL_VARIABLE_ACCESSOR_IDENTIFIER(variableName); | ||
} else { | ||
var value = REWIRED_DATA_IDENTIFIER[variableName]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just fixed the tabs to be consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of these vars
and so on are from original code, so should probably not be changed in this PR.
@speedskater I just noticed the |
Fixed an issue where modules were interpreted as commonjs even when es6 Removed direct imports of babel-types and babel-template
Can confirm this PR works in our new Babel 7 codebase |
@NilSet, @ilias-t, @damassi thank you all for your work on this pull request. I am currently not in the office but I will review it tomorrow in the evening. Regarding the branch, i think the current branch would indeed be version-1.1.0 branch. Neverthless I will try to merge the version 1.1.0 branch into master and than using this PR an if possible some other open PRs to create a 1.2.0 branch and based on this a 1.2.0-RC1. Regarding the var/const/let issues I would propose to remain with the vars until we reach babel 7 support, and to tackle this in a separate branch/PR. Is this procedure okay for you? |
That would be fantastic, thanks @speedskater 👍 |
I have a rebase onto 1.1.0 mostly done. I may switch to a less hacky solution for the template placeholder thing. |
I'll keep this pointed at master, but compare the branch with version-1.1.0 to see only my changes |
@NilSet thanks again for you PR. I have merged it into the 1.2.0 branch and puglished 1.2.0-rc.1 and on npm as a prerelease. |
@NilSet I also added you as a contributor to the README. I hope this is okay with you? |
1.2.0-rc.1 seems to be working great! |
@speedskater How has the feedback been? Do we look ok to merge version-1.2.0 into master and release it as latest? |
Also curious about the progress of this? Would love to see this merged :) |
Would love to see this merged! |
I've tried 1.2.0-rc.1 with the 7.0.0 babel release and am having an issue
Has anyone else tried with 7.0.0? |
@adamnoakes - I've tested with babel 7, seems to be working. |
Commit history doesn't look clean, @NilSet are you pointing to the correct branch or maybe to rebase again? |
@miguel-orange i done some more investigation and it works ok for me when i use babel cli but when using babel register i get the issues, not sure if it's an issue with this, babel register or my setup. Are you using babel-register? When i remove this plugin, everything compiles fine using babel-register. |
@speedskater Does this still need anything to be done before it can be merged to master? |
@speedskater has unfortunately gone missing :( That said, the |
@kibertoad @damassi sorry for beeing not available for the project over the last month and neglecting the project. Unfortunately, I am currently changing jobs and finishing my PhD thesis at the same time. Therefore it won't get better soon. I hope I will be able to contribute some improvement in the future, but it will take some time. |
Fixed an issue where modules were interpreted as commonjs even when es6
Removed direct imports of babel-types and babel-template
Fixes #209 maybe