requirejs

How to use NodeJS global module objects in RequireJS modules

℡╲_俬逩灬. 提交于 2019-12-23 08:54:04
问题 I decided to use RequireJS as my module loader in NodeJS. Unfortunately, the modules I define don't have access to some of the "global" objects that would be be available if the modules were loaded using the CommonJS method. This includes the objects that are located in the module scope, such as __dirname and __filename . Is there a relatively simple approach to using these objects in the RequireJS modules? 回答1: This is covered on the requirejs issues site on github (https://github.com

How to use NodeJS global module objects in RequireJS modules

[亡魂溺海] 提交于 2019-12-23 08:52:18
问题 I decided to use RequireJS as my module loader in NodeJS. Unfortunately, the modules I define don't have access to some of the "global" objects that would be be available if the modules were loaded using the CommonJS method. This includes the objects that are located in the module scope, such as __dirname and __filename . Is there a relatively simple approach to using these objects in the RequireJS modules? 回答1: This is covered on the requirejs issues site on github (https://github.com

RequireJS - Isolating jQuery versions and plugins within contexts

谁说我不能喝 提交于 2019-12-23 07:48:40
问题 I have a project which utilizes multiple require contexts and dynamically loaded jQuery versions and plugins. (The jQuery versions will be centrally sourced and will not be inlined). jQuery integrity for the host and each context as well as plugin isolation are critical. I am writing a loader plugin for RequireJS to handle the following use cases: Within a specific require context And without affecting the fn of the hosting page or any other require context, I would like to: Load any version

How to access modules bundled from webpack outside bundles/chunks

你离开我真会死。 提交于 2019-12-23 07:38:53
问题 Let me first say that I have tried searching for an answer to this and haven't found anything that works or even hints to it being possible. I recently moved from RequireJS configuration to rolling up with Webpack. In some places in our Groovy app we have have a script tag in a GSP that will access modules through RequireJS like so: <html> <body> ... <script> require([ 'jquery', 'customModule' ], function($, customModule){ // do something with jquery // ... // do something with customModule }

Tooltip Tether with requireJS

a 夏天 提交于 2019-12-23 07:26:36
问题 latest beta version (v4) of Bootstrap uses Tether js to position elements, I am unable to let it work in my Requirejs app. in my requirejs config I have the following shim's paths: { jquery: '/path/to/jquery', tether: '/path/to/tether' }, shim: { 'bootstrap': ['tether', 'jquery'] } And when I want to activate tooltips in my app, I use the following code which I think is correct function page_events() { requirejs(['bootstrap'], function(bootstrap) { $('[data-toggle="tooltip"]').tooltip(); });

Require JS in different levels of dependency

六月ゝ 毕业季﹏ 提交于 2019-12-23 06:11:30
问题 I'm working with Javascript and I'm working with a project too long to development application with Phonegap and googlemaps but now I focused in the code with Javascript, but now I've the next structure of directories and scripts inside js directory: ├── controlador │ └── DeviceController.js ├── launcher.js ├── libs │ ├── backbone.googlemaps.js │ ├── backbone.js │ ├── class.js │ ├── index.js │ ├── jquery.js │ ├── jquery.mobile.min.js │ ├── mustache.js │ ├── require.js │ └── underscore.js ├──

RequireJS different jQuery

戏子无情 提交于 2019-12-23 05:41:13
问题 I would like to use RequireJS to load jQuery (module I develop supposed to work in uncontrolled environment where jQuery might be already initialized), but there are some problems when require different versions of jQuery. Results are unexpectable. Inside require function block jQuery version is kind of random. What is wrong? Here is code to illustrate problem: <!DOCTYPE html> <html> <head> <script data-main="scripts/main" src="http://ajax.cdnjs.com/ajax/libs/require.js/0.24.0/require.min.js"

knockout component widget template requirejs html

≯℡__Kan透↙ 提交于 2019-12-23 05:16:06
问题 im implementing the widget example for knockout http://knockoutjs.com/documentation/component-overview.html loading template from external html with requirejs not working for me ko.components.register('like-or-dislike', { template: { require: 'text!files/component-like-widget.html' } }); i put the html containing the template in external html. replace "files/" with my relative path "/views/_leyout" and it's not working i need a text.js file that loads the html? any example ? 回答1: The answer

how does requirejs know to load a required js file before I ever mention the file name?

China☆狼群 提交于 2019-12-23 04:35:53
问题 I am looking @Domenic's simple example of using requirejs, from this answer: simple example for using require.js which I am including here. shirt.js: define({ color: "black", size : "large" }); logger.js: define(function (require) { var shirt = require("./shirt"); return { logTheShirt: function () { console.log("color: " + shirt.color + ", size: " + shirt.size); } }; }); main.js: define(function (require) { var shirt = require("./shirt"); var logger = require("./logger"); alert("Shirt color

Karma: Is it possible to load JavaScript files statically before the requirejs framework?

情到浓时终转凉″ 提交于 2019-12-23 03:20:06
问题 I'm wondering if it's possible to configure Karma (0.10.9) to load certain JavaScript files before its requirejs framework? The reason I'm asking is that Knockout registers as a module with RequireJS if the latter has been included before Knockout, and this breaks another module (which doesn't support RequireJS). Basically, our karma.conf.js looks as below: module.exports = function (config) { config.set({ basePath: "Scripts", frameworks: ['mocha', 'requirejs'], files: [ "knockout-2.2.1.debug