Giter Club home page Giter Club logo

Comments (3)

errorrik avatar errorrik commented on May 28, 2024

没太明白你的意思。根据你的文字描述,我的测试例子和结果如下,应该符合你的预期。

<!DOCTYPE html>
<html>
<head>
<script src="http://s1.bdstatic.com/r/www/cache/ecom/esl/2-0-8/esl.js"></script>
<script>
require.config({
    map: {
        '*': {
            echarts: 'echarts-upgrade'
        },

        nirvana: {
            echarts: 'echarts'
        }
    }
});

define('echarts', [], function () {
    return {name: 'echarts'};
});

define('echarts-upgrade', [], function () {
    return {name: 'echarts-upgrade'};
});

define('test', ['echarts'], function (echarts) {
    console.log('test - ' + echarts.name);
});

define('nirvana', ['echarts'], function (echarts) {
    console.log('nirvana - ' + echarts.name);
});

define('nirvana/sub', ['echarts'], function (echarts) {
    console.log('nirvana/sub - ' + echarts.name);
});

require(['test', 'nirvana', 'nirvana/sub']);
</script>
</head>
</html>

console结果:

test - echarts-upgrade
nirvana - echarts
nirvana/sub - echarts

所以我没太明白你的问题。anyway,esl优先级是按匹配度算的。nirvana能匹配上nirvana和*,但是最接近的是nirvana。nirvana/sub/sub2能匹配上nirvana和nirvana/sub,最接近的是nirvana/sub。这和require.config中的书写顺序无关。

from esl.

uraincay avatar uraincay commented on May 28, 2024

没有表述太清楚,不好意思。
注意我写的esl config

<!DOCTYPE html>
<html>
<head>
<script src="http://s1.bdstatic.com/r/www/cache/ecom/esl/2-0-8/esl.js"></script>
<script>
require.config({
    map: {
        '*': {
            echarts: 'echarts-upgrade'
        },

        nirvana: {
            deprecated: 'nirvana/deprecated'
        }
    }
});

define('echarts', [], function () {
    return {name: 'echarts'};
});

define('echarts-upgrade', [], function () {
    return {name: 'echarts-upgrade'};
});

define('test', ['echarts'], function (echarts) {
    console.log('test - ' + echarts.name);
});

define('nirvana', ['echarts'], function (echarts) {
    console.log('nirvana - ' + echarts.name);
});

define('nirvana/sub', ['echarts'], function (echarts) {
    console.log('nirvana/sub - ' + echarts.name);
});

require(['test', 'nirvana', 'nirvana/sub']);
</script>
</head>
</html>

console结果:

test - echarts-upgrade
nirvana - echarts
nirvana/sub - echarts

期望的结果是

test - echarts-upgrade
nirvana - echarts-upgrade
nirvana/sub - echarts-upgrade

from esl.

errorrik avatar errorrik commented on May 28, 2024

it seems be a bug

from esl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.