Coder Social home page Coder Social logo

Comments (7)

tommysitu avatar tommysitu commented on June 5, 2024 1

@FrancescoBorzi I had the same issue but it works after I changed my tsconfig.spec.json to use es2015 module for the compiler:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/spec",
//    "module": "commonjs",
    "module": "es2015",
    "types": [
      "jasmine",
      "node"
    ]
  },
  "files": [
    "test.ts",
    "polyfills.ts"
  ],
  "include": [
    "**/*.spec.ts",
    "**/*.d.ts"
  ]
}

from ngx-highlightjs.

MurhafSousli avatar MurhafSousli commented on June 5, 2024

The library does not have unit tests, and I cannot help on that regards. if you think it can fixed from this package and you know how to fix it, PRs are welcome!

But this is not a bug

from ngx-highlightjs.

FrancescoBorzi avatar FrancescoBorzi commented on June 5, 2024

@MurhafSousli of course this is a bug since using this directive breaks the tests

from ngx-highlightjs.

HYrelav avatar HYrelav commented on June 5, 2024

I get the same error if I use the curly-brackets like { xml } in the import, I removed the curly-brackets and the error left.
example: import xml from 'highlight.js/lib/languages/xml';

from ngx-highlightjs.

FrancescoBorzi avatar FrancescoBorzi commented on June 5, 2024

@HYrelav thanks for sharing this, however for me it doesn't work with or without curly-braces.

This is how I'm using it:

import sql from 'highlight.js/lib/languages/sql';

export function hljsLanguages() {
  return [
    { name: 'sql', func: sql },
  ];
}

export const highlightOptions = {
  languages: hljsLanguages,
};

// ...
imports: [
    //...
    HighlightModule.forRoot(highlightOptions)
  ]
// ...

also I've tested both targetting es5 and es6, it's broken on both.

from ngx-highlightjs.

FrancescoBorzi avatar FrancescoBorzi commented on June 5, 2024

@tommysitu thanks a lot, that works

from ngx-highlightjs.

mhamel06 avatar mhamel06 commented on June 5, 2024

I also found that importing the language with the * syntax also works in tests. e.g.

import * as xml from 'highlight.js/lib/languages/xml';

from ngx-highlightjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.