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.

Cannot use with r.js compiler of requirejs AMD system

See original GitHub issue

Hi there!

I cant compile in one file my amd modules (with you dependencies) because here https://github.com/amplitude/Amplitude-Javascript/blob/master/amplitude.js#L5 writen this code

return require('1')

can you change it on correct AMD wrapper Smth like this

(function (root, factory) {
  if(typeof define === "function" && define.amd) {
    // Now we're wrapping the factory and assigning the return
    // value to the root (window) and returning it as well to
    // the AMD loader.
    define(["postal"], function(postal){
      return (root.myModule = factory(postal));
    });
  } else if(typeof module === "object" && module.exports) {
    // I've not encountered a need for this yet, since I haven't
    // run into a scenario where plain modules depend on CommonJS
    // *and* I happen to be loading in a CJS browser environment
    // but I'm including it for the sake of being thorough
    module.exports = (root.myModule = factory(require("postal")));
  } else {
    root.myModule = factory(root.postal);
  }
}(this, function(postal) {
  // module code here....
  return myModule;
}));

Thank you!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
blazzycommented, Sep 13, 2017

Hey Folks, the latest version v3.6.0 is now being built as a proper umd module. Hopefully that solves the problems you were having.

0reactions
ravangencommented, Aug 4, 2017

You can load the script synchronously or edit the script (which you would need to do for each version upgrade).

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - r.js won't compile ES6 - Stack Overflow
I tried webpack, but it seems i can't get it work. I need the same output as r.js with unnamed defines to concatenated...
Read more >
RequireJS Optimizer
Combines related scripts together into build layers and minifies them via UglifyJS (the default) or Closure Compiler (an option when using Java). Optimizes...
Read more >
r.js - GitHub
A command line tool for running JavaScript scripts that use the Asynchronous Module Definition API (AMD) for declaring and using JavaScript modules and...
Read more >
Add non-AMD modules before AMD modules - AMD Community
Hi I'm using requirejs for a project and I have 2 modules: a.js: is a non-AMD module that I cannot touch its code...
Read more >
Can you help me understand the benefit of require.js?
You had a set of modules and compiled them into one file and did not use a module system - I am still...
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