MurhafSousli / ngx-highlightjs

Angular syntax highlighting module
https://ngx-highlight.netlify.app/
MIT License
273 stars 35 forks source link

This repo not support pnpm #272

Closed BppleMan closed 10 months ago

BppleMan commented 10 months ago

Reproduction

#this is typo:
pnpm i ngx-highlightjk
#actual:
pnpm i ngx-highlightjs

#when i use npm i ngx-highlightjs,then everything will be better

ng serve

Expected Behavior

run project

Actual Behavior

./src/main.ts:8:31-53 - Error: Module not found: Error: Can't resolve 'highlight.js' in '/Users/bppleman/coolbox/coolbox-gui/src'

Error: src/main.ts:11:49 - error TS2307: Cannot find module 'highlight.js' or its corresponding type declarations.

11                 fullLibraryLoader: () => import("highlight.js"),
                                                   ~~~~~~~~~~~~~~

Environment

MurhafSousli commented 10 months ago

its ngx-highlightjs

BppleMan commented 10 months ago

its ngx-highlightjs

@MurhafSousli

That's a typo, but the problem remains

MurhafSousli commented 10 months ago

I don't use pnpm, shouldn't it work like yarn? or I have to publish the package to pnpm?

thekhegay commented 6 months ago

@MurhafSousli I think the problem is with highlight.js resolving. pnpm or yarn pnp doesn't linking it.

Possible solution is installing directly to project: pnpm install highlight.js

thekhegay commented 6 months ago

@MurhafSousli second option:

add to .npmrc: public-hoist-pattern[]=*highlight.js*

thekhegay commented 6 months ago

@MurhafSousli so the idea is to make ngx-highlightjs works like solid package. Library should work like line-numbers

example:

coreLibraryLoader: () => import('highlight.js/lib/core'),
languages: {
  css: () => import('highlight.js/lib/languages/css'),
  scss: () => import('highlight.js/lib/languages/scss'),
  typescript: () => import('highlight.js/lib/languages/typescript'),
  xml: () => import('highlight.js/lib/languages/xml'),
},

should be replaced with:

coreLibraryLoader: () => import('ngx-highlightjs/highlight-lib'),
languages: {
  css: () => import('ngx-highlightjs/languages/css'),
  scss: () => import('ngx-highlightjs/languages/scss'),
  typescript: () => import('ngx-highlightjs/languages/typescript'),
  xml: () => import('ngx-highlightjs/languages/xml'),
},
MurhafSousli commented 6 months ago

This is a dependency, how can you receive updates and fixes from the main package then?

thekhegay commented 6 months ago

@MurhafSousli pnpm uses linking to node_modules: Flat node_modules is not the only way

So, for libraries there are 2 approaches:

MurhafSousli commented 6 months ago

I am afraid this is out of the scope for this project.

This is just a wrapper package of highlight.js and it depends on it, it works the standard npm. for other tools - developers should figure it out on their own.