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.

[v4] Requirejs makes life hard

See original GitHub issue

I’ve been trying to migrate to CM4 on our setup. Before we were shimming things using require.js but now I wanted to use the new loader that you’ve setup, but sadly the use of ../ at the beginning of a module id does not resolve to the relative path according to this issue jrburke/requirejs#550. The result is that all the addons can’t require their dependencies.

Issue Analytics

  • State:closed
  • Created 10 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
dignifiedquirecommented, May 26, 2014

@neochief for me the packages directive worked out:

require.config({
  packages: [
    {
      name: 'codemirror',
      location: '../js/CodeMirror',
      main: 'lib/codemirror'
    }
  ],
  paths: {
    jquery: '../../js/jquery/jquery-1.11.0.min'
  }
});

and then you can just do

define([
  'jquery',
  'codemirror',
  'codemirror/mode/javascript/javascript',
  'codemirror/mode/clike/clike',
  'codemirror/mode/php/php',
  'codemirror/addon/edit/matchbrackets',
  'codemirror/addon/hint/show-hint'
], function($, CodeMirror){
  var initialize = function(){
    var exp = CodeMirror.fromTextArea($('#export')[0], {
      lineNumbers: true,
      mode: "application/json"
    });
  }
  return {
    initialize: initialize
  };
});
0reactions
neochiefcommented, May 30, 2014

This worked perfectly, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[v4] Requirejs makes life hard · Issue #2389 · codemirror ... - GitHub
I've been trying to migrate to CM4 on our setup. Before we were shimming things using require.js but now I wanted to use...
Read more >
Optimising requirejs with r.js causes undefined errors
Two issues in your configuration which will cause mysterious problems: jQuery 1.9.1 does not need a shim. Remove the shim you've set for...
Read more >
RequireJS Reviews 2022: Details, Pricing, & Features - G2
Using a modular script loader like RequireJS will improve the speed and quality of your code. Makes life easier for you, for your...
Read more >
Basics of Require JS - Part 1 - YouTube
I discuss the basics of Require JS. Specifically define, config, and require functions. I talk about why you/your team would want to use ......
Read more >
Nextdoor Loves Webpack! - by Harry Kao
RequireJS is a dependency tracker and asynchronous loader that implements AMD. By default, it makes a ton of HTTP requests: one for each ......
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