-
Notifications
You must be signed in to change notification settings - Fork 91
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
compile using babel for compatibility with older versions #96
Conversation
65c739d
to
67c0a2b
Compare
The latest Rollup plugins don't work on older Node. I've avoided the build step for those versions now, but now tests are failing as Babel is insufficient as Babel doesn't polyfill globals like |
While I've gotten As far as earlier Node versions, |
Would need core-js on older Node versions to support the 's' flag but existing code shouldn't be using it anyways.
So I could try retooling the tests to point to the Alternatively, we could just avoid adding pre-Node 6 versions to travis and get out a patch earlier, trusting that babel is working (after this PR) as advertised. As far as the single Node 6 test failure, from what I can tell, the core-js polyfill for the RegExp constructor doesn't properly handle the dotall flag as I was still getting errors despite including the polyfill and successfully confirming it was being used. But older esquery dependencies shouldn't have been relying on the 's' flag anyways, as it had not been supported in esquery previously (nor would older environments support it), so while it would be good to see what we can do to get it to work under core-js, I think we could also drop Node 6 from Travis for now too (or ignore its result), given that this one failure is expected without a proper polyfill. Suggested steps forward? |
Btw:
|
@brettz9 what if we use a modern version of node to build everything, and then only run the tests in legacy versions of node? I was able to run the There are a few ways I could imagine doing this:
|
@mbroadst : Since @michaelficarra had indicated previously that he did not wish to bundle the distributions, yes, I think another way would need to be adopted to build (or obtain) the builds and test against them. Even if the building issues are addressed, those earlier Node environments will still fail on the (Btw, I don't see though how the original PR could have worked for you on Node 4 with the dotAll test. I also don't see how it could not have erred due to a lack of This is toward the end of my day over here (in China), btw, so you might want to look into devising a build solution on your own if you need a fix for the day. |
@brettz9 I'm looking into this now. You're correct that I hadn't got to the I think we still have more work to do here outside of the |
By moving toward ESM, I would think it would be better preparing for future maintenance (and is already doing so in allowing for ESM distributions). But yes, it is causing pains at the moment due in part to the fact that the toolers have themselves dropped support. How about I adapt the tests to avoid ESM in favor of pointing to the compiled |
@brettz9 I'm not against moving towards ESM at all, I'm just pondering the changes needed in order to support what's needed here compared to simply cutting a major release now. I think the approach you suggest would work, but we still end up with a travis configuration which is manually replacing dependencies for certain versions of node (etc) which is more what I'm getting at in terms of a maintenance burden. |
@brettz9 I am okay with limiting the new functionality to only the supported engines going forward. This means that the library just needs to load and provide at least the 1.1.x functionality on older platforms. Will that help simplify this PR? We can gate tests for newer features behind node version checks. |
@mbroadst I never mind a ping. Sorry about the delay, the week of a TC39 meeting is always nuts. @brettz9 I don't think we need to go through excessive effort to get old versions of node running our tests in CI. What we really care about is that the code we actually distribute will work in these environments. If you've manually tested it by converting the imports to requires and running the tests, that's sufficient. Is that enough guidance for you to move forward? |
Ok, after reverting tests from using imports (and pointing to I was not able to successfully install earlier versions of Node (using nvm) to find out whether earlier versions might work. So it seems pretty clear that his will continue to work on versions as far back as 0.10.0. @mbroadst , do you have any objections to my keeping the addition of this PR to add Btw, @michaelficarra , I've added a commit to drop testing previous to Node 6 (since it seems with the manual testing I've now done, you would like to keep the modern testing apparatus for the next (patch) release). And you can see that all automated tests are now passing as a result. |
One minor problem I have not been able to work around--though not sure we need to since |
@brettz9 I think that's probably fine, thank you very much for your hard work! |
@michaelficarra In case you didn't get a notice, this should now be ready for review. |
.travis.yml
Outdated
if [ ${node_version:1:1} -ge 6 ]; then | ||
echo "Node 6+" | ||
npm install --no-save "eslint@5" [email protected] [email protected] | ||
npm run test:ci |
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.
How are we running the tests without building (npm run build
) on this platform?
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.
Oh I see now. By not running the build step, we're testing against the old parser and will fail when we go to add a new feature.
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 don't recall if the build routine works or not (I can try for parity if you like), but it is not needed because the tests are able to run using @babel/register
testing against the source instead of dist
files.
(I only needed to switch to testing the dist
files in the branch where I manually confirmed the old Node builds were still working. But that branch had to undo ESM in the test files and fixtures, avoid other ES6 features, as well as revert to the vulnerable Mocha 3.)
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 don't understand. Why would we be able to run "against the source" using @babel/register
but not compile? Isn't @babel/register
just compiling on the fly and running that?
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.
On the much older Node versions, @babel/register
doesn't work (I switched those to avoid using babel register in favor of just testing against dist
), and babel-register
doesn't seem to be able to understand the import statements as @babel/register does.
As far as Node 6 that is failing on Travis, yes, @babel/register
is compiling on the fly so the babel component should be doable, but it appears that the current @rollup/pluginutils
(used by the current versions of @rollup/plugin-commonjs
and @rollup/plugin-node-resolve
needed in the Rollup config file) is using object spread properties which weren't supported in Node 6. Note that it wouldn't be enough to go back just to an older version here either, as these were previously not in the @rollup
scope but were their own packages. But if we go too far back in our toolchain, then certain other features might not have been supported then. And even if we can use the older Rollup deps. across machines, then it may mean adding a version with vulnerabilities.
Is it really critical that the build scripts are confirmed to work on Node 6? These aren't available to work in the npm releases anyways (since the rollup config is not in package.json
files
and Rollup, etc. are devDeps).
This should really only be needed for those compiling from source on the repo who would presumably have access to more up to date machines. Seems it may be some unnecessary work for little benefit (not to mention adding to the travis build time).
But I can try to see if we can get it to work for Node 6 if it is important.
This comment has been minimized.
This comment has been minimized.
Co-Authored-By: Michael Ficarra <[email protected]>
This is good enough for now. We'll deal with node 6 CI issues if/when they come up in the future. Thanks for the hard work, @brettz9. |
Thanks for all the thoughtful reviewing and merges! |
This should work (to close #95), but still need to add matrix logic to travis to install older nyc, etc. to confirm build is working