Requirejs: paths vs map

From the RequireJS Docs “In addition, the paths config is only for setting up root paths for module IDs, not for mapping one module ID to another one.” This means “paths” is meant for mapping just the path to your resource when it is not in the default location (baseUrl). I guess this is what … Read more

RequireJS: Multiple main.js?

The requirejs team has some samples for multipage applications on github. Have a look at: https://github.com/requirejs/example-multipage Basically you are going to have the following structure: page1.html: page 1 of the app. page2.html: page 2 of the app. js app: the directory to store app-specific modules. lib: the directory to hold third party modules, like jQuery. … Read more

How do I load third party JavaScript from a CDN when using RequireJS?

This will load jQuery from a CDN: <script src=”http://requirejs.org/docs/release/2.1.5/comments/require.js”></script> <script type=”text/javascript”> require.config({ paths: { “jquery”: “https://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min” }, waitSeconds: 40 }); </script> <div id=”message”>hello</div> <script type=”text/javascript”> require( [“jquery”], function ($) { alert($.fn.jquery + “\n” + $(“#message”).text()); } ); </script> Fiddle Here. This page from the requirejs docs shows how to eliminate a path from the optimised … Read more

module.exports “Module is not defined”

RequireJS cannot load CommonJS modules as-is. However, there is a minimal modification you can make to them to load them. You have to wrap them in a define call like this: define(function (require, exports, module) { module.exports = { Combobox: require(‘./combobox’), Option: require(‘./option’) }; }); If you have a bunch of modules you need to … Read more

What’s the correct way to use requireJS with typescript?

I would have commented on David’s reply to basarat’s answer (regarding modules and classes), but I don’t have the reputation. I know this question is stale, but I didn’t find an answer elsewhere. I succeeded by using basarat’s videos, combined with some other resources, to figure it out for classes like David Thielen needed. Note … Read more

Dependency injection in TypeScript

I have developed an IoC container called InversifyJS with advanced dependency injection features like contextual bindings. You need to follow 3 basic steps to use it: 1. Add annotations The annotation API is based on Angular 2.0: import { injectable, inject } from “inversify”; @injectable() class Katana implements IKatana { public hit() { return “cut!”; … Read more

Using Require.js without data-main

Yep, take a look at the documentation: http://requirejs.org/docs/api.html#config You need to call require.config() and set baseUrl. Based on your example: <script src=”https://stackoverflow.com/questions/12865630/scripts/require.js”></script> <script> require.config({ baseUrl: “scripts” }); require( [ /*…*/ ], function( /*…*/ ) { /*…*/ }); </script>

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)