-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
fix: fix node v12 #2109
fix: fix node v12 #2109
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/markedjs/markedjs/56pQ5vXq6RhaF5HDwsi6CuFFLU33 |
Aww no... my nice clean optional chaining... This looks fine. But any chance we can solve the problem by making use of Babel and emitting the es5 version instead of muddying up our source code? That's what Babel is for, right? |
Refactoring with babel could come as a separate PR but this fix should be deployed asap as lots of project deployments are broken because of it. |
We already generate a transpiled version of Marked with Babel that works with older versions of node. All we would need to do is change one line of code to emit that version by default. |
That's fine but v2.0.10 has become a broken change compare to v2.0.7. Could we at least make sure test passes before releasing the package? |
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.
👍
## [2.1.1](v2.1.0...v2.1.1) (2021-06-16) ### Bug Fixes * fix node v12 ([#2109](#2109)) ([af14068](af14068))
🎉 This PR is included in version 2.1.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Note - Marked 2.x supported node 8 from the start. jsdoc 3.x depends on marked@^2.x so will pick up any (breaking) node.js support changes that marked introduces. even if things get working on Node.js 12 with this fix, 2.x is still "broken" since jsdoc expects support for node 8.15. Right now there's nothing it can do except roll back and pin marked to a version that did support node 8 or inherit breaking changes whenever marked wants to drop a node version. |
@@ -83,6 +83,6 @@ | |||
"preversion": "npm run build && (git diff --quiet || git commit -am build)" | |||
}, | |||
"engines": { | |||
"node": ">= 8.16.2" | |||
"node": ">= 12" |
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.
It's one thing to ensure support in CI but it's another thing to change support in a minor version. I understand that only LTS/latest node versions are supported but real functional changes should only happen during a major version, otherwise it's going to break a lot of people.
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.
Sorry, left this a while back but forgot to submit...
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.
If jsdoc wants to support node v8 they could import the es5 version of marked
const marked = require('marked/lib/marked.js');
That should support node v4.
This is why the engines
field is misleading and I suggested removing it altogether in #1938 (review)
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.
For the record according to jsdoc engines field it only supports >=v14.17.1
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.
That's good to know that there's an alternative (i missed seeing it in the docs), but the point still kinda stands about the default import potentially breaking over time.
FYI the engines field you linked is on master (jsdoc 4.x prerelease), the current 3.x version is >=8.15.0)
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.
This change is breaking our CI build now. We use this through Typedoc, with that and our lib using Node >= 10.18.0
. It would be great if you could revert this change. This is a breaking change as per semantic versioning. I'd recommend you do this in a v3.x release and have a deprecation period to allow dependents to update their packages or find some other mitigation.
error marked@2.1.1: The engine "node" is incompatible with this module. Expected version ">= 12". Got "10.18.0"
error Found incompatible module.
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.
@Fleker Node.js 10 reached end of life in April and is no longer supported https://nodejs.org/en/about/releases/
You can probably disable that error if you really need to with yarn install --ignore-engines
@UziTech Looks like there are still breaking issues with this (might need to revert). I think we could solve a lot of problems (and open up the use of ES6 or even up to the latest ES2020 features in the source code) if we instead just default to the es5 version. |
@calculuschild The issues is not ES6 (aka ES2015). The issue is the use of optional chaining, which was introduced in ES2020. See the features and versions here: https://github.com/tc39/proposals/blob/master/finished-proposals.md This PR solves the root cause: we need to be testing in Node 12 if we intend to support it (thanks @UziTech for also updated In the future, we need to drop support (or rather introduce new ES features) under a major semver. |
@styfle You are correct, I meant to say ES2020. But the solution remains: if we supply the es5 version as the default then we can still use optional chaining, whatever ES2020/ ES2015 feature we want in the source, since Babel nicely converts it all to a version that is compatible with older Node versions. It used to be that the ES6 version of Marked.js ran slightly faster, but that is also no longer the case; I see no reason not to supply the Babelified ES5 version to users. Using optional chaining is not a breaking feature needing a major semver change if it gets transpiled out anyway. This would also allow us to roll back the Node version change in this PR so that we aren't dropping support outside of a major semver change. That is the entire purpose of the existence of Babel: to make newer ES features backwards-compatible. All we need to do, from my understanding is change this line: Line 6 in da1c57f
to this:
|
@calculuschild we should also change the ci to testing the built version. I don't know how that will affect PRs or stack traces. Maybe we need to add sourcemaps as well? I feel like this small change isn't as small as first thought. I'm all for defaulting to es5 version, especially if it is faster, but I think we will have to think through all of the implications. |
Good points. I believe the rollup-plugin-babel package that we already use has an option to generate sourceMaps which should be just an option to set. As for getting into the ci I wouldn't know where to start for this project. |
Marked version: 2.1.0
Description
remove optional chaining to fix node v12 support
update engines to support node v12
test on node v12
Contributor
Committer
In most cases, this should be a different person than the contributor.