valeriangalliat / markdown-it-anchor

A markdown-it plugin that adds an `id` attribute to headings and optionally permalinks.
The Unlicense
291 stars 72 forks source link

ES6 babel issue #40

Closed windmaomao closed 5 years ago

windmaomao commented 6 years ago

I followed this, https://babeljs.io/docs/setup/#installation, and then include

md.use(require('markdown-it-anchor/lib'), {})

seems solved const issue when including into project which do not have babel on node_modules folder.

windmaomao commented 6 years ago

I wish I don't need to do the following,

import Anchor from '../assets/markdown-it-anchor'

Right now, I can't load directly from node_modules, because all ES6 stuff won't get translated inside webpack.

So, either I do babel on your repo, or I do custom import like the above.

nagaozen commented 6 years ago

This is a known limitation. Nowadays JS grounds are really unstable. In many of my own projects translating node_modules is required anyway because too many packages are using ES6 features. Some developers just stick with ES2015 and never use ES6, others suggests transpiling before publishing. Even in FB it's an open issue. It's probably better to stick with ES2015 because the codebase will be really backwards compatible, but it's a lot of work to convert, test, cover and deploy this project and related ones. Also, it's like going against the flow and losing lots of improments like async module loading, named imports and other stuff built with that system in mind.

nagaozen commented 5 years ago

Branch 2019-stack should fix this.