enterprise standard loader

Overview

ESL (Enterprise Standard Loader)

ESL是一个浏览器端符合AMD的标准加载器,适合用于现代Web浏览器端应用的入口与模块管理。

ESL is a browser-only, amd-compliant module loader. In modern web applications, it is normally used in startup script or as a module manager.

通过右键另存的方式下载ESL (Download by Save As):

了解AMD (About AMD)

ESL vs RequireJS

  • 体积更小 (Smaller)
  • 性能更高 (Higher performance)
  • 更健壮 (More Robustness)
  • 不支持在非浏览器端使用 (Browser only)
  • 依赖模块用时定义 (Lazy define)

ESL的配置项 (CONFIGURATION OPTIONS)

查看 ESL的配置文档

See Configuration Options

CDN

当前版本的CDN引用:(latest)

<!-- compressed -->
<script src="http://s1.bdstatic.com/r/www/cache/efe/esl/2-1-6/esl.js"></script>

<!-- compressed(https) -->
<script src="https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/efe/esl/2-1-6/esl.js"></script>

<!-- source -->
<script src="http://s1.bdstatic.com/r/www/cache/efe/esl/2-1-6/esl.source.js"></script>

过往版本 (Old version)

体积对比 (FILE SIZES)

uglifyjs -mc + gzip

  • esl 2.1.6 3.5k
  • requirejs 2.3.5 6.5k

性能对比 (PERFORMANCE)

查看 wiki文档

See wiki page

了解ESL的进化史 (CHANGE LOG)

了解ESL的进化史(CHANGE LOG)

错误信息 (ERROR MESSAGE)

阅读 ESL 中的错误提示信息 一文,以帮助您使用 ESL 时进行错误追查与调试。

Comments
  • 小是小,但问题不少

    小是小,但问题不少

    简单试用了一下,就发现了不少问题: 1.里面的正则定得有点“随便”,如我把path的某个key定义为$,然后就跑不了 2.按假设主入口为main,main require page, page依赖base,base依赖app,然后会发现app和base的factory都没有跑起来,只有page会跑 3.然后我都不敢再试下去了orz

    opened by lsycxyj 27
  • 增加_noRequest配置项

    增加_noRequest配置项

    require([ 'main', 'ui' ])
    

    对于上面的代码,在线上环境,main里面可能打包了ui的define,额外的ui请求是无意义,浪费网络资源的。虽然系统运行的正确性没问题。所以,增加_noRequest配置项。

    说明:

    • 非AMD标准配置项,所以命名以下划线开头。
    • Array.<string>,每一项规则和AMD的配置项保持一致:prefix match。
    • 对于符合规则的模块,不发送加载的请求。
    opened by errorrik 16
  • requirejs 与 esl 加载 echarts 的问题

    requirejs 与 esl 加载 echarts 的问题

    情况描述:

    在以下的两个DEMO中,用 esl 加载的 echarts ,虽然控制台报出 'echarts/chart/line' not found (http status 404) ,但是似乎并不影响啥,图表仍旧绘制;而用requirejs 加载的那个DEMO,报错不会绘制图表。

    说明:

    • esl , requirejs 皆是最新的 release 版本;
    • echarts 采用 echarts 提供的在线构建工具构建,AMD方式打包;

    esl:http://blog.supertree.me/demo/line.html

    requirejs:http://blog.supertree.me/demo/line-require.html

    问题:

    • esl 里对 require([Array],callback)的处理是否是只要有一个依赖加载成功,即执行callback,前提条件是callback里只有一个param,且依赖都打包在一个文件里,就如DEMO中那样:
    require([
        'echarts',
        'echarts/chart/line'
    ], function(ec) {
       // code
    });
    
    • 我看了一下规范,规范里只说依赖加载OK,就执行 callback,也没说非得依赖非得全部没问题,才执行 callback ,关于这点,上面的两个 DEMO 也能看出 requirejs 与 esl 处理方式也是不同的,所以想问问你们是怎么理解的?

    That's all. Thanks.

    opened by Phinome 11
  • 软依赖加载完前可能已经执行代码

    软依赖加载完前可能已经执行代码

    复现环境不太好弄,今天我修改ESUI时,跑测试始终出现这样的错误:

    [MODULE_MISS]esui/Helper is not exists!

    我的代码大概是这样的:

    function Control(options) {
        options = options || {};
    
        var Helper = require('./Helper');
        /**
         * 控件关联的{@link Helper}对象
         *
         * @type {Helper}
         * @protected
         */
        this.helper = new Helper(this);
    
    }
    

    var Helper = require('./Helper');拿到构造函数外面,做成硬依赖就不会出这事了。根据断点,是先进入了这个构造函数,再进入Helperfactory执行,似乎软依赖放过的条件有些太过宽松,导致在依赖确实加载完以前代码被执行了

    我估计和上次与你说的问题同一个,先留个底

    opened by otakustay 10
  • 没有把依赖的模块作为回调函数的参数时,导致依赖的模块的factory函数不执行

    没有把依赖的模块作为回调函数的参数时,导致依赖的模块的factory函数不执行

    当define一个模块时,没有把依赖的模块作为回调函数的参数时,导致依赖的模块的factory函数不执行,例如:

    //mod a file
    define('a',[],function(){
        console.log('a factory call');
    });
    
    //mod b file
    define('b',[],function(){
        console.log('b factory call');
    });
    
    //mod all file
    define('all',['a','b'],function(a){ //这里参数没有b
        console.log('all factory call')
    })
    /call
    require(['all'], function() {
        console.log('all callback');
      })
    
    //执行结果
    a factory call a.js:2
    all factory call all.js:2
    all callback 
    
    //其中b factory call 没有执行
    
    opened by winnieBear 8
  • 讨论下延迟factory执行的问题

    讨论下延迟factory执行的问题

    先叫上人:@errorrik @leeight @firede @Justineo @wangyang0123 @chriswong @PengXing @treelite

    最近requiejs把factory改成第一次require时才执行了,所以我觉得这个话题我们也可以讨论一下

    factorydefine时就执行主要会存在这样的问题:

    当有些依赖是“概念上”而非“编码”上存在时,如果对模块进行合并,且在factory执行中直接依赖这些“概念依赖”,则会出错

    此类问题很容易在shim一类的模块上出现,以es5shim为例:

    foo.js

    define(function () {
        // forEach在es5shim中
        getArray().forEach(...
    });
    

    main.html

    <script>
        require(['es5shim'], function (es5shim) {
            es5shim.enable(); // 假设shim必须手动启用
            require('foo');
        });
    </script>
    

    由于main.html作为唯一的入口,会保证es5shim已经加载并完成了对原生对象的扩展,所以在正常使用中并不会出错。

    但如果把es5shimfoo合并在一起,则一定出错。

    此问题可以通过延迟factory的执行来实现,当require('foo')执行时es5shimmain.html保证肯定已经准备完毕。

    和CMD的区别

    如果把factory延迟执行,模块管理会非常类似于CMD,但又和CMD不同。CMD是通过对源码分析,将局部require都改为全局的,将同步代码改为异步的来实现,可能存在一些问题:

    1. 遇上不可预期的函数执行延迟,原本预期所有依赖全部完毕,函数执行可控,但被自动修改为异步require后,可能函数执行一半要进行远程脚本的加载
    2. 异步丢失调用堆栈等信息,虽然Chrome最近可以保留异步堆栈了,但毕竟还没普及
    3. 使用callee的可能就直接挂了

    因此在AMD的基础上实现延迟的factory执行并不代表我们使用了CMD

    可能遇到的负面作用

    1. 同样不可预期的函数中断,因为require可能代表着一个或一系列的factory的执行,且这个执行时间很可能和用户的操作路径相关,函数执行时间变得不那么可控,性能监控的数据的分析难度也随之加大
    2. loader会不会为之有一些额外的负担,目前不明

    我们要怎么做

    由于业务项目中很容易遇到本文最前面说的情况,因此我觉得延迟factory执行是一个切实的需求

    我建议再多一个esl-delayed.js的文件,不影响当前esl的实现,至于代码怎么复用,这是小问题

    opened by otakustay 8
  • `relative2absolute` 的问题

    `relative2absolute` 的问题

    RT,relative2absolutebaseId 值为形如 "http://..." 的字符串时,返回结果中的 // 会只剩一个,即:

    relative2absolute('./a', 'http://baidu.com/b') // 返回结果为 "http:/baidu.com/a"
    

    这个表现为在全局环境以完整 url 的形式加载匿名模块时,如果该模块有相对路径的依赖,则该依赖的路径会计算错误。

    require(['http://baidu.com/xxx'], function(m){console.log(m)}) // `http://baidu.com/xxx` 内部有相对路径依赖
    

    主要原因是在这里对 seg 对了非空的判断,不知道这是出于什么考虑。

    opened by nighca 5
  • 能否增加一个类似require.js的data-main

    能否增加一个类似require.js的data-main

    如题,在require.js里面data-main属性指向的文件这个文件会第一个被require.js加载。这样的话,在开发过程中就可以少一个script标签引入config文件。

    <script data-main="js/config" src="js/require.js"></script>
    
    opened by Yunhui 5
  • esl 和 require 功能似乎不完全一致,与 jquery 和jquery ui配合的问题。

    esl 和 require 功能似乎不完全一致,与 jquery 和jquery ui配合的问题。

    问题: esl 不能有效 加载 jquery 和jquery ui。

    说说背景:因为我要使用echart,后来又要使用zrender,所以就使用了esl。 后来又要使用 jquery ui,所以想继续使用 esl 来加载 jquery ui【备注,之前jquery一直是静态标签加载的】。 因为 jquery ui的需要, 所以改为 amd 方式 加载 jquery, 但是 require之后, 在浏览器中看页面代码, jquery 和 jquery ui的相关代码文件也都正确加载了,script标签都正确,但就是没有 那个 $, jQuery变量, 还有 jquery ui的相关部件 函数也没有加载到jquery的 fn中。且也不报错。

    后来偶然机会试了网上的例子, 又在自己的 程序里试了 require.js 这个库,发现 jquery 和jquery ui的部件 可以正常使用了, 再换回 esl.js, 又不行了。再换回 require.js,又可以了。 所以我的初步判断是 esl 似乎在某些方面 有些不完备。

    我不是js 专家,也是把 esl 当作 require.js 来使用的,所以这种差别, 还是有些困惑的。 下面贴上我的配置:

                 var  zr, tl;
    
        require.config({ 
            //baseUrl: 'resource/js',
            packages: [
                  {name: 'jquery', location: 'resource/js', main: 'jquery'},
                  {name: 'jqueryui', location: 'resource/js/jqueryui/ui', main: 'jqueryui' },
                {   name: 'zrender',
                    location: 'resource/js/zrender', 
                    main: 'zrender'
                }
            ]
        });
    
        require([   'zrender/zrender'
                    ,'zrender/shape/Circle'
                    ,'zrender/shape/Rectangle'],
                    function(zrender,_, _, timeline) {
                        //this.zrender = zrender;
                        this.zr = zrender.init(document.getElementById('cmain'));
                    }
        );
    
        require(['jquery'], function($){ //虽然网上有资料说这里要jquery,但试了 jquery/jquery 在require.js 时 也可以成功加载。
            console.log($);     //使用 require.js的时候,这里可以运行到,esl的时候不行,且不报错。
        }); 
    
        require(['jqueryui/dialog'], function(dialog){
            console.log(dialog);  //使用 require.js的时候,这里可以运行到,esl的时候不行,且不报错。
        }); 
    
    opened by yeyanzhao 5
  • 支持esl-config.json

    支持esl-config.json

    现在edp install pkg之后,会自动生成一个esl-config.json的文件,一个示例的格式如下:

    {
        "packages": [
            {
                "name": "esl",
                "location": "lib/esl/0.0.1"
            },
            {
                "name": "jquery",
                "location": "lib/jquery/1.9.1",
                "main": "./src/jquery.min.js"
            },
            {
                "name": "tangram",
                "location": "lib/tangram/1.3.7",
                "main": "./src/tangram.min.js"
            }
        ]
    }
    

    这个文件的内容应该是作为require.config的一部分,esl应该支持一个参数能够自动的加载这个文件。

    opened by leeight 5
  • 一个比较严重的bundle bug, header上多次添加同一bundle模块url

    一个比较严重的bundle bug, header上多次添加同一bundle模块url

    // src/main.js
    ==========
    define('A', {}); define('B', {}); define('C', {});
    ==========
    
    // esl config
    ==========
    baseUrl: src,
    bundles: {
        main: ['A', 'B', 'C']
    }
    ==========
    
     // console输入
    require(['A']); require(['B']);
    
    // 结果
    ==========
    
    d868df7d8196ecdfaaa803f61
    opened by uraincay 4
  • docs: Fix a few typos

    docs: Fix a few typos

    There are small typos in:

    • test/impl/inject/inject.js
    • test/tests/doh/_browserRunner.js

    Fixes:

    • Should read adhering rather than adhearing.
    • Should read string rather than stirng.
    • Should read resolved rather than resovled.
    • Should read amenable rather than ammenable.

    Semi-automated pull request generated by https://github.com/timgates42/meticulous/blob/master/docs/NOTE.md

    opened by timgates42 0
  • esl 与 requirejs 表现不一致的地方

    esl 与 requirejs 表现不一致的地方

    目录结构

    project\ (根目录)
                js\ ( js 目录 )
                   lib\ ( 库目录 )
                        esl.js 
                        require.js
                   main.js ( data-main 对应的 ) 
                   app1.js ( app1.html 用的 )
                css\ 
                app1.html
    
    app1.html 部分代码
    
    注意: 如果这里使用 requirejs 则不会报错
    使用 esl.js 会报 project/tweenmax.js net::ERR_FILE_NOT_FOUND
    
    <script src="./js/lib/esl.js" data-main="js/main"></script>
    <script>
        // 使用 requirejs 这里换成 require(['app1']);
        require(['js/app1']);
    </script>
    
    main.js 部分代码
    
    require.config({
        baseUrl:'js',
        paths: {
            'tweenmax': './lib/tweenmax.min',
    
        },
        shim: {
            'tweenmax': {
                exports: 'TweenMax'
            }
        }
    });
    
    
    app1.js 部分代码
    define(function (require) {
        var TweenMax = require("tweenmax")
        // var GSDevTools = require("GSDevTools")
    
    })
    

    如果描述不够请给我留言,使用 esl.js 有一段时间了,体积比 require.js 要小,不太想放弃,还请帮忙排查下,感觉应该是自己水平不够对路径转换理解比较浅造成的原因

    opened by MonchiLin 1
  • require 模块失败后,再次 require 该模块不会重新加载

    require 模块失败后,再次 require 该模块不会重新加载

    问题描述:esl 环境中,在断网的情况下 require 模块失败,在连网后再次触发 require 该模块 不会触发该模块的加载。

    通过阅读esl源码,个人认为问题原因为:无论模块加载成功与否,loadingModules[moduleId1] 都会赋值为 1,导致即使后来再次 require([moduleId1]) 也不会进入到新建 script 加载的逻辑。 b3342b8d4424eeb44a9866869

    建议: 在此挂接 onerror 的错误处理,重新赋值 loadingModules[moduleId1] 为 0,使得加载某个模块失败后,还能重新加载该模块。 6efd7efdb7ff3ea797adcf437

    opened by ghost 0
  • 调用require函数时   data-main指定的文件尚未加载完成.

    调用require函数时 data-main指定的文件尚未加载完成.

    在页面通过data-main加载main.js文件: <script src="esl.js" data-main="main"></script> 然后在该页面使用 require(['jquery'], function() { console.log(jQuery); }); 提示加载jQuery模块失败, 原因是执行require函数的时候 main.js 文件尚未加载完成, 所以没有找到jquery的配置信息, 这里是否可以优化一下呢? 以下代码可以正常运行, 但是很鸡肋: setTimeout(function() { require(["jquery"], function() { console.log(jQuery) }) }, 500)

    另外 , data-main指定的路径不能使用相对目录吗? 如果我的页面目录层级不一致, 那么data-main指定的路径也不一致, 这样开发web项目的时候不利于使用模板技术生成布局页面了吧?

    opened by Sunw730 0
Owner
Baidu EFE team
Baidu EFE team
A Module Loader for the Web

A Module Loader for the Web Sea.js is a module loader for the web. It is designed to change the way that you organize JavaScript. With Sea.js, it is p

seajs 8.3k Jan 3, 2023
curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.

curl (cujoJS resource loader) All development for curl.js and cram.js has stopped. For the foreseeable future, we will continue to respond to issues o

The Javascript Architectural Toolkit 1.9k Dec 30, 2022
:skull: An ancient tiny JS and CSS loader from the days before everyone had written one. Unmaintained.

LazyLoad Note: LazyLoad is no longer being maintained. I'm not responding to issues or pull requests, since I don't use this project anymore and don't

Ryan Grove 1.4k Jan 3, 2023
Asyncronous JavaScript loader and dependency manager

$script.js - Async JavaScript loader & dependency manager $script.js is an asynchronous JavaScript loader and dependency manager with an astonishingly

Dustin Diaz 2.9k Jan 3, 2023
Dynamic ES module loader

SystemJS SystemJS is a hookable, standards-based module loader. It provides a workflow where code written for production workflows of native ES module

null 12.4k Dec 29, 2022
OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on almost any browser of your choice.

OpenUI5. Build Once. Run on any device. What is it? OpenUI5 lets you build enterprise-ready web applications, responsive to all devices, running on al

SAP 2.7k Dec 31, 2022
🌋 Pluggable enterprise-level react application framework.

English | 简体中文 umi ?? Extensible enterprise-level front-end application framework. Please consider following this project's author, sorrycc, and consi

UmiJS 13.5k Jan 1, 2023
The best JavaScript Data Table for building Enterprise Applications. Supports React / Angular / Vue / Plain JavaScript.

Module SonarCloud Status ag-grid-community ag-grid-enterprise AG Grid AG Grid is a fully-featured and highly customizable JavaScript data grid. It del

AG Grid 9.5k Dec 30, 2022
🌈 An enterprise-class UI components based on Ant Design and Vue. 🐜

Ant Design Vue An enterprise-class UI components based on Ant Design and Vue. English | 简体中文 Features An enterprise-class UI design system for desktop

vueComponent 17.6k Jan 9, 2023
Enterprise-grade JavaScript snow effect for the internets, setting CPUs on fire worldwide every winter since 2003.

/** * DHTML Snowstorm! JavaScript-based Snow for web pages * -------------------------------------------------------- * Version 1.44.20131208 (Prev

Scott Schiller 518 Dec 24, 2022
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications on top of TypeScript & JavaScript (ES6, ES7, ES8) 🚀

A progressive Node.js framework for building efficient and scalable server-side applications. Description Nest is a framework for building efficient,

nestjs 53.2k Dec 31, 2022
🥚 Born to build better enterprise frameworks and apps with Node.js & Koa

Features Built-in Process Management Plugin System Framework Customization Lots of plugins Quickstart Follow the commands listed below. $ mkdir showca

egg 18.3k Dec 29, 2022
Rollup + Babel + Prettier + Strict ESlint + VSCode - Enterprise grade boilerplate

Javascript package boilerplate by HackingBay Rollup + Babel + Prettier + Strict ESlint + VSCode - Enterprise grade boilerplate Minimalist js package b

HackingBay 1 Dec 28, 2021
Rollup + React + Babel + Prettier + Strict ESlint and Stylelint + Sass + VSCode + Playground app - Enterprise grade boilerplate

React package boilerplate by HackingBay Rollup + React 17 + Babel + Prettier + Strict ESlint and Stylelint + Sass + VSCode + Playground app - Enterpri

HackingBay 2 Jan 19, 2022
The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.

CKEditor 4 - Smart WYSIWYG HTML editor A highly configurable WYSIWYG HTML editor with hundreds of features, from creating rich text content with capti

CKEditor Ecosystem 5.7k Dec 27, 2022
An enterprise-class UI components based on At UI Design and Angular. 🚀 🚀 🚀

An enterprise-class UI components based on At UI Design and Angular. ?? ?? ??

塟愛鎵镞de栤仯 113 Dec 16, 2022
A framework dedicated to making it easier for you to build enterprise-grade PWA applications.

A framework dedicated to making it easier for you to build enterprise-grade PWA applications.

JerryC 181 Oct 6, 2022
An enterprise-class React UI components library

KDesign of React KDesign of React 是基于金蝶的企业级设计系统KDesign 实现的一套React UI组件库,主要用于企业级系统的构建。 特性 提供开箱即用的 丰富的企业级 React UI 组件。 使用 TypeScript 开发,提供完整的类型定义文件。 组件全

金蝶云苍穹开源 43 Dec 30, 2022
Toolkit for development, test and deploy smart-contracts on Waves Enterprise ecosystem.

JS Contract SDK Toolkit for development, test and deploy smart-contracts on Waves Enterprise ecosystem. Quickstart The fastest way to get started with

Waves Enterprise 20 Dec 15, 2022
Open-Source Serverless Enterprise CMS

Webiny developer community writing program. Contribute to the open source movement by writing technical content. And get paid for doing so!!!

Webiny 23 Dec 29, 2022