requirejs

How do i solve error “cannot find module 'jquery'” in my Typescript build

坚强是说给别人听的谎言 提交于 2020-01-11 13:52:10
问题 I currently have this at the top of my "ts" files import $ = require("jquery"); I am doing this because I am trying to use jquery in my typescript files, but i cant seem to get it to compile because it returns the error stated in the title. I am using ASP.NET CORE Script Folders tsonfig.json { "compilerOptions": { "noImplicitAny": true, "noEmitOnError": true, "sourceMap": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "target": "es5", "module": "umd" }, "files": [

RequireJS: Set path to 'ignore'

眉间皱痕 提交于 2020-01-11 10:49:31
问题 I'm using a third-party library (through bower) that declares a dependency that I do not want (it's just styling). Is it possible to set that dependency to 'ignore,' or some such value? e.g.: define(['jquery','dep_i_dont_want'], function(){...}); In require config: paths: { 'jquery': 'path/to/jquery', 'dep_i_dont_want': 'ignore' } I would just require to look up 'dep_i_dont_want', see that it is ignored, and move on without including it or failing. Is this possible? I do not want to edit the

RequireJS: Set path to 'ignore'

☆樱花仙子☆ 提交于 2020-01-11 10:49:16
问题 I'm using a third-party library (through bower) that declares a dependency that I do not want (it's just styling). Is it possible to set that dependency to 'ignore,' or some such value? e.g.: define(['jquery','dep_i_dont_want'], function(){...}); In require config: paths: { 'jquery': 'path/to/jquery', 'dep_i_dont_want': 'ignore' } I would just require to look up 'dep_i_dont_want', see that it is ignored, and move on without including it or failing. Is this possible? I do not want to edit the

add mustache temple to require in require.js AMD

允我心安 提交于 2020-01-11 07:38:30
问题 In js you can load a html template in the require part while defining a module. For example: template file : test.html <script id="test" type="text/template"> <div class="q-header-holder"> <h1> {{ quizName }}</h1> <a href="{{ instructionLinks }}" class="q-instruction-btn">Instructions</a> </div> </script> in module define( ["template/test"], function() { //.. rest of code .. } ); But this throws error while fetching the file the filename appended with .js extension. Is there any way to

require.js text plugin adds “.js” to the file name

不打扰是莪最后的温柔 提交于 2020-01-11 04:30:27
问题 I'm trying to work with requirejs and text plugin and I have weird problem. I have two web servers: localhost:3000 - act as CDN and has all the static files: js, images, css and templates localhost:3001 - server - act as REST server and serve only one file, the main.html file The main.html file loads all the js files from the second server using the following line: <script data-main="http://localhost:3000/js/main" src="http://localhost:3000/lib/require-jquery.js"></script> For some reason,

Require.js not compiling single js file correctly

天涯浪子 提交于 2020-01-10 01:12:13
问题 I'm trying to build my require.js modules to one javascript file for production. The command I'm running is... r.js -o name=main out=main.min.js mainConfigFile=main.js This compiles but the compiled main.min.js file is not compiled correctly and still includes the "define" statement blocks. and the browser obviously returns Uncaught ReferenceError: define is not defined My main.js file looks like: require.config({ paths: { jquery: 'libs/jquery/jquery', }, shim: { bootstrap: { deps: ['jquery']

Fastadmin 如何引入 layui 模块

时光毁灭记忆、已成空白 提交于 2020-01-09 22:32:42
FastAdmin,PHP,Fastadmin引入layui模,fastadmin使用layui。 FastAdmin基于 RequireJS 进行前端JS模块的管理,因此如果我们需要再引入第三方JS插件,则必按照 RequireJS 的规则进行载入。如果你还不了解什么是 RequireJS ,可以先简单了解下 RequireJS ,相关链接: http://www.ruanyifeng.com/blog/2012/11/require_js.html FasrAdmin 前台文件在 require-frontend.js 或 frontend-init.js 后台文件在 require-backend.js 或 backend-init.js 对应的文件,定义插件的名称和依赖。 其中 require-frontend.js 和 require-backend.js 是官方自己的写好的依赖和插件。而打开 frontend-init.js 和 backend-init.js 我们可以发现是空白的。那正好用于我们自己编写,方便管理。 接下来我们就在 backend-init.js 中添加如下代码: define(['backend'], function (Backend) { require.config({ paths: { 'layui': '../libs/layerui

Accessing the functions in express on client side using the require — Node js

不打扰是莪最后的温柔 提交于 2020-01-07 02:47:06
问题 I have a to access the config variables defined in the file called test.js which has -- var aws = require('aws-sdk'); exports.connect = function(){ return aws; } Now I need to access it when the OnClick event occurs on the browser. I have this script but the require module does not work. clientScript.js var aws = require('../scripts/test.js').connect(); function getValue() { aws.describe({},function(){...}) } How can I access this aws variable? 回答1: You can't use require() on the client side,

Reloading / reinitializing / refreshing CommonJS modules

北战南征 提交于 2020-01-06 19:31:32
问题 I understand CommonJS modules are meant to load once. Lets say we have a Single Page application with hash based navigation, when we navigate to a previously loaded page the code is not re-run as it has already been loaded once which is what we want. How can I get the content of the module to reload as though it wasn't already initialized? For example, if I have some data in local storage that changes, how can I run a function to update this data and/or what would be the best way to update

JavaScript mixins

岁酱吖の 提交于 2020-01-06 15:28:49
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> mixin 是一个类,该类的方法被添加,混合进另外一个类。 一个基础类会包含mixin类的方法而不是继承它。这样你就可以使用不同的mixin类来增加或者增强基础类的功能。 这编内容包含怎么样使用javascript mixin来重写Magento组件的方法。 Mixin Scope 一个模块的作用域(scope)取决于其在view目录下的目录位置。这样你就可以定位magento特定位置的特定组件实例。 下表对minxin应用区域和其目录位置做了映射。 Directory Scope view/frontend Storefront view/adminhtml Admin panel view/base All areas (unless a specific frontend or adminhtml entry exists) Mixin文件 位置 Minxins是在特定区域目录web/js目录下的javascript文件。只要mixin文件在web/js目录下,它可被嵌套到多个目录。 格式 Magento内的mixin被写成一个返回回调方法的AMD模块。这个方法接收目标组件(模块)作为参数同时会返回一个模块。 举例: 扩展UI组件(component)