Skip to content
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

This repo not support pnpm #272

Closed
BppleMan opened this issue Nov 6, 2023 · 9 comments
Closed

This repo not support pnpm #272

BppleMan opened this issue Nov 6, 2023 · 9 comments

Comments

@BppleMan
Copy link

BppleMan commented Nov 6, 2023

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

  • Angular: 16.2.0
  • ngx-highlightjs: 10.0.0
  • Browser(s): nothing
  • Operating System (e.g. Windows, macOS, Ubuntu): macOS
@MurhafSousli
Copy link
Owner

its ngx-highlightjs

@BppleMan
Copy link
Author

BppleMan commented Nov 6, 2023

its ngx-highlightjs

@MurhafSousli

That's a typo, but the problem remains

@MurhafSousli
Copy link
Owner

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

@thekhegay
Copy link

@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
Copy link

@MurhafSousli second option:

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

@thekhegay
Copy link

@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
Copy link
Owner

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

@thekhegay
Copy link

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

So, for libraries there are 2 approaches:

  • Add instructions for pnpm: as i said
    • users needs to install highlight.js directly to their projects
    • or add public-hoist-pattern[]=*highlight.js* to .npmrc
  • Add re exports:
    •  const core = import('highlight.js/lib/core');
       export default core;
      

@MurhafSousli
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants