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

.js suffix for highlightjs dependency #47

Closed
divyakumarjain opened this issue Aug 10, 2015 · 8 comments
Closed

.js suffix for highlightjs dependency #47

divyakumarjain opened this issue Aug 10, 2015 · 8 comments

Comments

@divyakumarjain
Copy link

I am trying to use angular-highlightjs with requirejs. because of dependency on "highlight.js" (notice th .js suffix) require tries to load highlightjs from application base path. Following extract from requirejs api

RequireJS also assumes by default that all dependencies are scripts, so it does not expect to see a trailing ".js" suffix on module IDs. RequireJS will automatically add it when translating the module ID to a path. With the paths config, you can set up locations of a group of scripts. All of these capabilities allow you to use smaller strings for scripts as compared to traditional <script> tags.
There may be times when you do want to reference a script directly and not conform to the "baseUrl + paths" rules for finding it. If a module ID has one of the following characteristics, the ID will not be passed through the "baseUrl + paths" configuration, and just be treated like a regular URL that is relative to the document:

  1. Ends in ".js".
  2. Starts with a "/".
  3. Contains an URL protocol, like "http:" or "https:".

source: http://requirejs.org/docs/api.html

Also have a sample to play with.

https://jsfiddle.net/shg4wnfs/3/

@pc035860
Copy link
Owner

Hi @divyakumarjain

I find that highlight.js is actually using different module names on npm(which is highlight.js) and as an AMD module(which is hljs).

I'll fix this ASAP. Thank you for your report.

@pc035860
Copy link
Owner

pc035860 added a commit that referenced this issue Aug 12, 2015
Since webpack has some strange behavior on identifying the module name(see
webpack/webpack/issues/919), try to trick it with half-strict CommonJS
pattern.
@pc035860
Copy link
Owner

Hi @divyakumarjain, should be fixed. It's on master now.

@cAhmad
Copy link

cAhmad commented Nov 6, 2015

Hi,

I have the same issue while using ES2015 modules with jspm. It try to load highlight.js which does not exist.

@pc035860
Copy link
Owner

pc035860 commented Nov 7, 2015

@cAhmad I just released v0.5.0, which should have fixed the issue.

@cAhmad
Copy link

cAhmad commented Nov 12, 2015

Hi, thanks for your new release.

But, it tries now to load hljs.js file which does not exist.
Don't know if it helps but I'm working with jspm, the module to load in my case is highlightjs

@pc035860
Copy link
Owner

@cAhmad I haven't use jspm before, I'll take a look this weekend.

Though it's very weird that it tries to load hljs.js in this case (seems to have different behavior than webpack), it won't work even if it reads the correct module name, which is highlight.js, since the CommonJS pattern module name used in the angular-highlightjs's UMD pattern is based on highlight.js's npm package name, not highlightjs (this one is the name on component).

I guess you still have to use jspm to install the highlight.js on npm, rather than the one in jspm's official registry.

So it's kind of difficult to support all kinds of module loaders these days...

@cAhmad
Copy link

cAhmad commented Nov 18, 2015

Thanks for your reply.

I will use the npm version instead of the gihub one. If I got time I'll try some overrides.

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