GitbookIO / plugin-katex

Math typesetting using KaTex
Apache License 2.0
60 stars 37 forks source link

katex=0.8.1 cannot be loaded with error "unexpected token import" #16

Closed shunliz closed 7 years ago

shunliz commented 7 years ago

with katex=0.8.1, plugin load will fail, complain as below

debug: readme found at README.md debug: summary file found at SUMMARY.md debug: cleanup folder "C:\Users\zsli\AppData\Local\Temp\tmp-10564ld8oP2BXSmdZ" info: 10 plugins are installed info: 8 explicitly listed info: loading plugin "katex"... ERROR

PluginError: Error with plugin "katex": Unexpected token import

cimi commented 7 years ago

I have the same problem, it worked until very recently.

info: install plugin "katex" (*) from NPM with version 1.1.3
[project path]
├── gitbook-plugin-anchor-navigation-ex@1.0.10
├─┬ gitbook-plugin-callouts@0.1.1
│ └─┬ cheerio@0.19.0
│   └─┬ htmlparser2@3.8.3
│     └── domutils@1.5.1
├─┬ gitbook-plugin-katex@1.1.3
│ └─┬ katex@0.8.1
│   └── match-at@0.1.0
├── gitbook-plugin-mermaid-gb3@2.0.0
├── gitbook-plugin-prism@2.2.1
├─┬ gitbook-plugin-todo@0.1.3
│ └─┬ cheerio@0.19.0
│   └─┬ htmlparser2@3.8.3
│     └── domutils@1.5.1
└── gitbook-plugin-toggle-chapters@0.0.3

Starting up the server fails because katex can't load. If I remove katex from the list of plugins everything works fine.

$ gitbook serve
Live reload server started on port: 35729
Press CTRL+C to quit ...

info: 14 plugins are installed
info: 11 explicitly listed
info: loading plugin "prism"... OK
info: loading plugin "callouts"... OK
info: loading plugin "mermaid-gb3"... OK
info: loading plugin "anchor-navigation-ex"... OK
info: loading plugin "toggle-chapters"... OK
info: loading plugin "katex"... ERROR

PluginError: Error with plugin "katex": Unexpected token import

I am using the latest version of everything:

$ gitbook --version
CLI version: 2.3.2
GitBook version: 3.2.2

$ node --version
v8.2.1 (also tried with v6.9.1)

$ npm --version
5.3.0

The main katex package the plugin depends on was updated two days ago. I see that the plugin's package.json is configured so that updates are automatically picked up:

    "dependencies": {
        "katex": ">=0.5.1"
    }

This should be locked down to the latest known stable version.

cimi commented 7 years ago

@SamyPesse PR #18 fixes this, I've been using it locally through npm link.

It would be great to get this merged in soon as this issue breaks all builds that use katex.

cimi commented 7 years ago

👍 Thanks!

I was literally looking up the documentation for npm publish as I wanted to fix the build failures by publishing my changes under a different name.

@AaronO I see that you did not merge my commit that included the package version bump. Please publish a new version of the package on npm so we can actually use it.

AaronO commented 7 years ago

@cimi Publishing a new release in ~10mn.

I started reviewing your PR, but it included a lot of unnecessary (some bad) changes (like changing the README, repo URL, version), the only change required was locking katex to 0.7.1. So rather than leave a review with a bunch of comments I just went ahead and committed the core change :)

It's usually a considered a bad practice to bump as part of a pull request (because it's trivial for the maintainer to bump a new version once it's on the master).

In general pull requests should be focused on solving a single well defined problem and avoid modifying extra files (makes it longer to review and harder to merge). So as a general measure, the smaller the PR the better :)

(Just some friendly advice for next time, I appreciate you taking the time to actually submit a PR :D)

AaronO commented 7 years ago

@cimi Voilà, a 1.1.4 release is out with your fix !

cimi commented 7 years ago

I started reviewing your PR, but it included a lot of unnecessary (some bad) changes (like changing the README, repo URL, version), the only change required was locking katex to 0.7.1. So rather than leave a review with a bunch of comments I just went ahead and committed the core change :)

Those changes should not have been part of the PR - I didn't realise github automatically includes all future commits on the originating branch in the pull request. The changes in the second commit (README, name, repo etc.) were done because I was going to publish gitbook-plugin-katex-es5 so that I can unblock my build. The original PR (first commit) only had the katex version change and the version bump.

Thank you for resolving! 🎉