-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Error when using rollup with highlight.js? #4116
Comments
For now I'd try using the cdn-release instead which should have "real" ES6 modules... |
@joshgoebel the build is for an open source web component that uses highlight.js to do what it does ... but with a custom element ... and rollup is being used to bundle highlight.js into the component ... So crossing my fingers for a fix |
Repeating: For now I'd suggest using the cdn-release instead which should have "real" [independent] ES6 modules... ...which is exactly what you are asking for. We purposely bundled the npm library the way we did (per the docs) and at this late point in the game that's probably not changing. Version 12 will be ESM only, until then the cdn-assets build should suffice for anyone wanting to re-bundle ES6. https://www.npmjs.com/package/@highlightjs/cdn-assets/v/11.10.0 |
@joshgoebel I tried this, and it looks like Typescript does not have a way of importing from CDN assets ... |
I linked you to the NPM package where we publish all the assets as an npm package. You don't need to actually import them from a CDN - you just need the files. Importing should be the same as with any other npm package. |
@joshgoebel ooooh - OK - It's looking more realistic now :). I tried this import:
But Typescript creates this error ( Looks like
Do you by chance have a workaround for this to? Thanks for all your help this. |
That is a warning, not an error... but I really don't know further, sorry. |
May be related to the |
@joshgoebel for me it shows up as an error.
4 import hljs from '@highlightjs/cdn-assets/highlight.js'; Found 1 error in src/my-dispatcher.component.ts:4 I"ll keep plugging away at it though. I think I may just have to forgo using Typescript for this project, and do pure Javascript instead. Thanks again for all the input. |
Got same error with rollup [!] Error: 'default' is not exported by ../../node_modules/highlight.js/lib/index.js, imported by ../../node_modules/highlight.js/es/index.js error Command failed with exit code 1. |
A simple build against our ESM CDN builds (and cdn_release) with rollup should work just fine: (just built from
|
Probably not what you want, the |
And using the Node ESM build:
|
Pasting in the below description from this issue on SO:
https://stackoverflow.com/questions/78971938/using-rollup-with-highlight-js
I'm trying to use rollup to build a bundle containing
highlight.js
.This is the starter project I'm using to build the bundle. If we clone it and run:
We can see that the bundle is built without any errors.
And if we add
highlight.js
and import the default intosrc/my-dispatcher.component.ts
, the following error is created.Import the default.
Reference
hljs
on a property so that we don't get any linting errors.If we now run
npm run rollup
again the following error is produced.Thoughts?
Just for reference this is the rollup configuration.
The text was updated successfully, but these errors were encountered: