wooorm / refractor

Lightweight, robust, elegant virtual syntax highlighting using Prism
MIT License
724 stars 34 forks source link

Update `prism` to `1.21.0` #32

Closed chenxsan closed 4 years ago

wooorm commented 4 years ago

Thanks. Do you need help with this? Btw, the error about eslint-plugin-prettier does not occur when using npm I believe?

chenxsan commented 4 years ago

@wooorm Indeed, It works fine with npm while Cannot find module 'eslint-plugin-prettier' with yarn.

chenxsan commented 4 years ago

I've two problems now:

  1. TypeError: Cannot read property 'keyword' of undefined:

image

It might be caused by jsdoc.js using typescript loaded after it. (Found an issue here https://github.com/wooorm/refractor/issues/7)

  1. I don't know how to generate the fixtures, are they generated manually?
chenxsan commented 4 years ago

I've pushed another commit to fix the first issue according to https://github.com/wooorm/refractor/commit/c7f8b5d6f76e44f571fd498da616bd62517762cc, but I found the code would be overwritten if we run npm test again which means the CI will always fail.

wooorm commented 4 years ago

Code is generated, here is where dependencies are detected with Babel: https://github.com/wooorm/refractor/blob/main/script/languages.js#L123

Fixtures are by hand indeed, see here for a couple of lines you can comment out to regenerate: https://github.com/wooorm/refractor/blob/54d22680ceab1abb5f124c82e92135daf33ff37d/test/index.js#L261

chenxsan commented 4 years ago

I found the languages.js file uses regular expressions to get the deps, I'm wondering whether we can read its value from prismjs/components.json where they have this require attribute? I've pushed a new commit here https://github.com/wooorm/refractor/pull/32/commits/89421624632a2ce2cd70df527fda2dbc632adc25. As you can see it changed a lot of code, would love to hear your thought about it.

wooorm commented 4 years ago

Oh nice! That as 't there when I originally made refractor. For your commit, you should remove the defaults: https://github.com/wooorm/refractor/blob/main/script/bundled.json

chenxsan commented 4 years ago

Both script/list.js and script/support.js depends on bundled.json, so I can't remove it naively.

wooorm commented 4 years ago

I’m sorry that my comment was unclear! I meant: you can use the bundled file, to remove stuff. For example, JavaScript requires are not needed: https://github.com/wooorm/refractor/pull/32/files#diff-a067b044e29ecf0bf62f582853f9b9d6R2, because they are already registered! I think that’s the main reason for your earlier comment: “As you can see it changed a lot of code, would love to hear your thought about it.”

chenxsan commented 4 years ago

@wooorm It's me misunderstood your comment. I've pushed a new commit, hope it's right this time :)

wooorm commented 4 years ago

Thanks! Released in 3.1.0! ✨