marked icon indicating copy to clipboard operation
marked copied to clipboard

Breaking change in 2.1.0

Open HunderlineK opened this issue 5 years ago • 22 comments

Marked version: 2.1.0

Describe the bug The latest code uses the optional chaining operator which makes marked 2.1.0 incompatible with Node V12. It's breaking semantic release which uses Marked. Here: https://github.com/markedjs/marked/commit/5be9d6d70ea35be6398ee35958fb8ac955a89fbe

Thanks!

HunderlineK avatar Jun 16 '21 00:06 HunderlineK

@UziTech Shouldn't Babel be able to handle this?

calculuschild avatar Jun 16 '21 00:06 calculuschild

This is affecting our Node 12 CI as well.

glasser avatar Jun 16 '21 02:06 glasser

const marked = require("marked") in node uses /src/marked.js not the transpiled es5 version at /lib/marked.js

The problem is that marked is only tested in lts/*(v14 currently) and latest (v16 currently) but the ?. syntax doesn't work in v12.

We had a discussion in https://github.com/markedjs/marked/pull/1938#discussion_r574175702 about what versions of node marked should support

UziTech avatar Jun 16 '21 02:06 UziTech

(Dropping support for Node 12 is totally reasonable — just publish a rollback version at 2.1.1 and publish the version that doesn't support Node 12 as 3.0.0.)

glasser avatar Jun 16 '21 02:06 glasser

Broke our CI too, via pulling in protobufjs - upgrading to node 14+ seems get past the issue, but we can't do that as a solution for other reasons.

utsavkapoor avatar Jun 16 '21 02:06 utsavkapoor

Yes, I'm discovering that the protobufjs CLI runs a bunch of unversioned (!) npm installs at runtime (!) which pull in marked recursively.

glasser avatar Jun 16 '21 03:06 glasser

@glasser - Has anyone reported this to protobufjs ?

utsavkapoor avatar Jun 16 '21 03:06 utsavkapoor

protobufjs is barely maintained. we use our own fork of it and I'm trying to figure out a way to untangle its web of hackery, but honestly if [email protected] supported Node 12 and [email protected] was what you published as 2.1.0 it would solve this problem. "No longer runs under a major version of Node that's still in LTS" is a pretty clearly semver-major change.

glasser avatar Jun 16 '21 03:06 glasser

const marked = require("marked") in node uses /src/marked.js not the transpiled es5 version at /lib/marked.js

@UziTech Should Marked supply the es5 version by default? The transpiled version seems to run slightly faster on the benchmarks anyway. We already have Babel doing the work for us but our documentation doesn't give any hint on how to access it for people who need that compatibility.

calculuschild avatar Jun 16 '21 03:06 calculuschild

The transpiled version seems to run slightly faster on the benchmarks anyway.

It didn't when we started transpiling it which is why we stuck with main pointing to the es6 version, but it seems to have gotten faster over time so maybe we should?

/cc @styfle

UziTech avatar Jun 16 '21 03:06 UziTech

(We're working around it by changing our project's build system to not run the protobufjs CLI automatically on every install but just manually with checking in the generated code, which means the CLI doesn't have to run on every Node version we support.)

glasser avatar Jun 16 '21 04:06 glasser

For those running into this problem with Next.js on Vercel (and I guess any other hosted build platform)

22:00:37.460 | Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error
22:00:37.460 | /vercel/path0/node_modules/marked/src/marked.js:158
22:00:37.460 | const prevRenderer = extensions.renderers?.[ext.name];

You can fix this by upgrading the node version to 14x in your Vercel project settings!

brendanmc6 avatar Jun 16 '21 05:06 brendanmc6

Just FYI, this is also breaking Twilio CLI's flex plugin:

$ DEBUG=* twilio flex:plugins:deploy --patch --changelog="test deploy"

/Users/xxxxxx/.twilio-cli/node_modules/marked/src/marked.js:158
          const prevRenderer = extensions.renderers?.[ext.name];
                                                    ^

SyntaxError: Unexpected token '.'
    at compileFunction (<anonymous>)
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/xxxxxx/.twilio-cli/node_modules/flex-dev-utils/dist/marked.js:7:32)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)

Thanks for looking into it!

david-amores-anz avatar Jun 16 '21 06:06 david-amores-anz

tldr have broken on node 12 https://tldr.sh/ 😭

taikulawo avatar Jun 16 '21 09:06 taikulawo

protobufjs is using markedjs and looks like did not lock the version, so it's blocked our production release. Save our live please 😭

installing semver@^7.1.2
installing chalk@^4.0.0
installing jsdoc@^3.6.3
installing uglify-js@^3.7.7
installing espree@^7.0.0
installing estraverse@^5.1.0
/temp/node_modules/protobufjs/cli/node_modules/marked/src/marked.js:158
          const prevRenderer = extensions.renderers?.[ext.name];
                                                    ^

SyntaxError: Unexpected token '.'
    at new Script (vm.js:88:7)
    at createScript (vm.js:263:10)
    at Object.runInThisContext (vm.js:311:10)
    at wrapSafe (internal/modules/cjs/loader.js:1034:15)
    at Module._compile (internal/modules/cjs/loader.js:1097:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Object.load (/temp/node_modules/protobufjs/cli/node_modules/requizzle/lib/loader.js:105:18)
    at Requizzle.requizzle (/temp/node_modules/protobufjs/cli/node_modules/requizzle/lib/requizzle.js:87:31)
    at infectProxy (/temp/node_modules/protobufjs/cli/node_modules/requizzle/lib/loader.js:79:31)
    at Module.targetModule.require (/temp/node_modules/protobufjs/cli/node_modules/requizzle/lib/loader.js:97:44)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/temp/node_modules/protobufjs/cli/node_modules/jsdoc/lib/jsdoc/util/markdown.js:8:16)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
/temp/node_modules/protobufjs/cli/pbts.js:133
                throw err;
                ^

Error: code 1
    at ChildProcess.<anonymous> (/temp/node_modules/protobufjs/cli/pbts.js:130:27)
    at ChildProcess.emit (events.js:322:22)
    at maybeClose (internal/child_process.js:1021:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
error Command failed with exit code 1.
child_process.js:669
    throw err;
    ^

cctv1237 avatar Jun 16 '21 09:06 cctv1237

I've found some workaround, maybe it will help someone

Call it before using protobufjs / pbjs

cd node_modules/protobufjs/cli && npm i && npm i [email protected]

4eb0da avatar Jun 16 '21 10:06 4eb0da

Hi! This issue just bit us.

I've found some workaround, maybe it will help someone

Call it before using protobufjs / pbjs

cd node_modules/protobufjs/cli && npm i && npm i [email protected]

Is this really the only solution right now? We're using yarn v2 and tried the resolutions field in our package.json but it doesn't work. yarn why marked yields no output at all.

josefschabasser avatar Jun 16 '21 11:06 josefschabasser

We're using yarn too and fixed this in the following way:

yarn add --dev [email protected]
yarn add --dev jsdoc@^3.6.3

Alternatively you can also force marked@^2.0.3 to use 2.0.3.

The main thing is to install jsdoc yourself.

Nilos avatar Jun 16 '21 12:06 Nilos

As a workaround for our use case, we fixed the semantic-release to "semantic-release": "17.3.6",

HunderlineK avatar Jun 16 '21 13:06 HunderlineK

:tada: This issue has been resolved in version 2.1.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] avatar Jun 16 '21 13:06 github-actions[bot]