amd

TypeScript: import module with only statements

家住魔仙堡 提交于 2019-12-05 07:57:13
I have a page-a.ts which would compile into page-a.js : alert('this is from page-a'); And I have a main.ts which compiles into main.js : import pageA = module('page-a') alert('this is from main'); And this is my tsc command line: tsc --module amd page-a.ts main.ts And I'm using requirejs like this: <script src="require.js" data-main="main.js"></script> I can't see the alert messagebox from page-a when loading the page. And in the generated scripts main.js , there is nothing about page-a . My question is, why is this happening? And how do I force typescript to import a module that is not

TypeScript+SystemJS using JSON and Text plugins

最后都变了- 提交于 2019-12-05 05:42:51
Using TypeScript with SystemJS , how can I import a JSON file using plugin-json ? If I write System.import('myjson.json!json').then(...) then it imports it asynchronously and not as a part of System.register([...]) . So, how can I import a JSON file as a part of System.register([...]) and convincing TypeScript to agree to this? (without then Promise syntax). Note: I'm using the tsc flag -m system Update: A possible solution is to use the -m umd option for tsc instead of -m system , then I can do the following: /// <reference path="typings/requirejs/require.d.ts" /> var myJson = require('myJson

RequireJS: module ID vs module name

扶醉桌前 提交于 2019-12-05 04:32:22
问题 I'm kinda noob in RequireJS; I recently read the API documentation, and came across these two terms: module ID and module name . Are they used interchangeably? Or are they somehow different concepts? Excerpts: http://requirejs.org/docs/api.html#jsfiles RequireJS also assumes by default that all dependencies are scripts, so it does not expect to see a trailing ".js" suffix on module ID s. RequireJS will automatically add it when translating the module ID to a path. http://requirejs.org/docs

CommonJS,AMD/CMD,ES6之间模块的区别

北慕城南 提交于 2019-12-05 04:23:13
一、CommonJS CommonJS 模块就是对象,用于服务器端编程(webpack 是以CommonJS的形式来书写) CommonJS 定义的模块分为: {模块引用(require)} require()用来引入外部模块; {模块定义(exports)} exports对象用于导出当前模块的方法或变量,唯一的导出口; {模块标识(module)} module对象就代表模块本身。 CommonJS模块特点: CommonJS 是 同步加载模块 ,模块加载的顺序,按照其在代码中出现的顺序。 所有代码都运行在模块作用域,不会污染全局作用域。 模块可以多次加载,但是只会在第一次加载时运行一次,然后运行结果就被缓存了,以后再加载,就直接读取缓存结果。要想让模块再次运行,必须清除缓存。 二、AMD(RequireJS)、CMD(SeaJS) RequireJS与SeaJS 模块是可以是对象 函数 构造器 字符串 JSON等各种类型的模块,用于浏览器端编程 RequireJS与SeaJS模块特点: RequireJS与SeaJS 是 异步加载模块 CMD推崇 依赖就近 ,AMD推崇 依赖前置 AMD里require分全局的和局部的,CMD里面没有全局的 require,提供 seajs.use()来实现模块系统的加载启动,CMD里每个API都简单纯粹。 ES6 模块不是对象

How to load custom AMD modules when using Dojo via CDN?

六月ゝ 毕业季﹏ 提交于 2019-12-05 01:39:51
I am using google's CDN and also trying to load my own AMD modules using their loader. I know I'm doing something wrong but I'm stuck. Any ideas? <script src="https://ajax.googleapis.com/ajax/libs/dojo/1.7.0/dojo/dojo.js" type="text/javascript" data-dojo-config="async:true,parseOnLoad:true"></script> <script type="text/javascript"> require(["dojo/_base/kernel", "dojo/_base/loader", "dojo/parser"], function(dojo){ dojo.registerModulePath("pgGallery", "http://127.0.0.1:8080/js"); }); require(["pgGallery/Message"], function(m){ m.success("foo"); }); </script> http://127.0.0.1:8080/js/Message.js

How do I load AMD modules when using Angular JS?

女生的网名这么多〃 提交于 2019-12-05 01:38:15
问题 For some strange reason Angular JS has its own module system that is neither AMD nor CommonJS. I have many existing modules in AMD format. I would like to use them in an Angular app. I would like to avoid rewriting any AMD modules. If possible, I would also like to avoid using Angular's own module system. Is it possible to use AMD modules when using Angular? is it possible to avoid Angular's custom module system? 回答1: You do need to define Angular components in the "Angular way" (ex. angular

Requirejs - Configuring require before loading data-main

99封情书 提交于 2019-12-04 22:55:16
问题 We're using requirejs for the first time, and I'm having trouble structuring my dependencies. I've defined my main app.js file as the data-main attribute in my index.html: <script data-main="src/app" src="/js/lib/require/require.js"></script> But, I have a file which defines all my require path/shim configurations, and I want that to run before the app.js file. I need it to run so that I can reference configured paths as dependencies in my app.js. I don't think the right way is to put my

Typescript module creation AMD vs Common JS

女生的网名这么多〃 提交于 2019-12-04 22:51:26
Can any Typescript experts clarify when and why you would choose AMD vs Common JS for module creation when using Typescript? AMD is used in the browser (e.g RequireJS) : reason is it allows parallel download of files as network latency is a major bottleneck. CommonJS is used in the server (e.g. nodejs) where files can be read from disk upfront, but you don't want to read a file till you try to use the code it contains. Here is a video on the subject that further explains this : http://www.youtube.com/watch?v=KDrWLMUY0R0 Are you using require.js? Use AMD Are you using node.js? Use CommonJS Don

Require.js module not seeing Backbone Router.js

僤鯓⒐⒋嵵緔 提交于 2019-12-04 21:12:02
In this simple Require/Backbone app https://github.com/thisishardcoded/require-prob Why does app.js see Router but TestView.js not? Here is the first line of app.js define(['router'],function (Router) { and here is the first line of TestView.js define(['backbone','router'],function(Backbone,Router){ Check out the repo for full details, download, run and check console log if you feel so inclined Thanks! Jim More: Ok, the answer is - because of the order in which it is loaded and even if that were altered I have a circular dependency don't I? TestView needs Router, Router needs TestView. In

Is there any guarantee that all of threads in WaveFront (OpenCL) always synchronized?

雨燕双飞 提交于 2019-12-04 19:52:40
As known, there are WARP (in CUDA) and WaveFront (in OpenCL): http://courses.cs.washington.edu/courses/cse471/13sp/lectures/GPUsStudents.pdf WARP in CUDA: http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#simt-architecture 4.1. SIMT Architecture ... A warp executes one common instruction at a time , so full efficiency is realized when all 32 threads of a warp agree on their execution path. If threads of a warp diverge via a data-dependent conditional branch, the warp serially executes each branch path taken, disabling threads that are not on that path, and when all paths complete