question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to not add a .js extension to dependency module

See original GitHub issue

I’m submitting a feature request

  • Library Version: 0.18.0
  • Operating System: OSX 10.x
  • Node Version: 6.2.0
  • NPM Version: 3.8.9
  • Browser: all
  • Language: TypeScript 1.9

Current behavior: When adding a dependency to the aurelia.json file it automatically adds a .js extension. I’m running into the issue of trying to load the square javascript library which can only be used with their cdn. The cdn url does not have a .js extension https://js.squareup.com/v2/paymentform.

Expected/desired behavior: Have an extra option field where you can disable the adding of the .js extension or maybe a cleaner way to let the bundler know not the add the .js extension.

What is the motivation / use case for changing the behavior? Trying to add payment processing to my app using square (https://squareup.com/). They don’t allow their library to be used outside of their cdn so they don’t have any npm or bower modules. I’ve tried adding a script tag in my index.html page but I can’t use the library inside any of my classes since Aurelia does not know of the global variables from that file. I tried adding it to my dependencies like so:

{
   "name": "paymentform",
    "path": "https://js.squareup.com/v2/paymentform",
    "exports": "SqPaymentForm"
 },

But since Aurelia adds the .js extension it never finds the link

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
3cpcommented, Jun 2, 2022

Current cli doesn’t support deps defined with path starting with http(s)://. It could be some dropped feature since v0.18.0.

I am pretty sure the previous feature uses requirejs config paths, where requirejs adds “missing” .js. That’s not in our control.

requirejs.config({ 
  paths: {
    "paymentform": "https://js.squareup.com/v2/paymentform"
  }
  ...

However, that js lib is in legacy format, only suppling a global var SqPaymentForm, it should be loaded by prepend instead.

Unfortunately cli’s prepend doesn’t support remote link.

The successor of cli bundler, dumber bundler does support remote url in prepend and append. I tested it, confirmed "https://js.squareup.com/v2/paymentform" works without the annoying .js.

0reactions
3cpcommented, Jun 2, 2022

I don’t think this is in our control, it’s the default behavior of requirejs when loading module from remote.

Update: I think I misunderstood. Is this some js code loaded by prepend? Nvm, I will have a look in a day or two.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is it possible to stop requireJS from adding the .js file ...
I'm using requireJS to load scripts. It has this detail in the docs: The path that is used for a module name should...
Read more >
JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript module syntax.
Read more >
add-js-extension - npm
The problem is that TypeScript, when it emits import statements, i.e. when you have set the "module": "ESNext" property in your tsconfig.json , ......
Read more >
RequireJS API
js ". The path that is used for a module name should not include an extension, since the path mapping could be for...
Read more >
Adding assets (CSS, JS) to a Drupal module via *.libraries.yml
"Attach" the library to a render array in a hook. But in the case of themes, there is an alternative to step 3:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found