Git Product home page Git Product logo

Comments (6)

mailaneel avatar mailaneel commented on May 27, 2024

This is happening when using version 1.0.2

from r.js.

jrburke avatar jrburke commented on May 27, 2024

For issue 1, where you see duplicates, if you mean that you see the modules show up in 'production.js' and 'ws.sideBar.js', use the exclude directive in the build file for ws.sideBar.js:

    modules: [
    {
        name: "production"
    },
   {
        name: "web.sideBar",
        exclude: ["production"]
    }

For Issue 2, dynamic require([]) inside a define() call will not be included unless the dependency is a string literal. So if the require looks like:

define(function(require) {
    //a should be included in the build
    require(['a'], function () {});

    var dep = 'b';
    //b will not be included in the build
    require([dep], function () {});
});

Note that for 1.0.3 by default r.js will not scan for require([]) calls inside a define, unless findNestedDependencies: true in the build config. This is also true if you happen to be using r-edge.js, which is a build of the latest code in the repo (contains all the fixed 1.0.3 issues so far).

If you are saying the require(['a'], function(){}) use above is not found in 1.0.2, if you can point to a specific code reference, or show the define() with the nested require([]) call that would be helpful in tracking down the issue.

from r.js.

mailaneel avatar mailaneel commented on May 27, 2024

For issue 1, i am talking about i18n, order plugins being included twice or thrice and also text dependencies are included twice. And i understand the exclude directive but production is not defined as dependency for web.SideBar module, so why should we exclude it. And if you see the gist attached you can check the build file and resulted file.

I am not a expert in build process but below is my understanding, please correct me if i am wrong:

My assumption is if a file or plugin is included once in the build it should not be included again for example there should not be two or three define('i18n',function(){}); , but i am seeing a file being included 2 or 3 times, My understanding is if i use the build tool a file or dependency will be included only once even if multiple files or multiple modules define the same dependency.

Scenario

if i have 2 modules TopBar, SideBar, both have dependency on a Model, and say i have a file called production which depends on
TopBar and SideBar. Now i want to build 3 modules TopBar,SideBar,Production.

My assumption:
SideBar and TopBar build file should have Model file include in them
Production build file should have SideBar file, TopBar file and Model file

But the outcome is Production file has SideBar build file, TopBar build file which means Model file is included twice and this is not the desired behavior according to me

Example: Gist
In the above link please search for define('i18n you will see this module included 2 times

Specific Code as requested for last point in the comment above

If i use the require in the renderUI function it is not build please see below

define('web.app',
    [
    'text!web/app/css/app.css',
    'i18n!web/app/nls/i18n' 
    ],function(css,language){

        wsl.provide('web.app');  

        web.app = wsl.Controller.sub();

        web.app.extend({
            module: {
                name: 'web.app',
                css: css,
                lang: language
            }
        });

        web.app.include({
            events: {},
            elements: {},
            init: function(){
            },
            start: function(){
                this.bindEvents();
            },
            bindEvents:function(){
                $(document).ready(this.proxy(this.onReady)); 
            },
            onReady: function(){
                wsl.log('Application is ready to use','warn'); 
                this.renderUI();
            },
            //this one should also be changed according the application requirements
            renderUI: function(){
                require(['text!web/app/html/base.html!strip'],function(html){
                    var options = {
                        element: $('body'),
                        tpl: html,
                        module:web.app.module
                    };

                    wsl.module.render(options); 
                });

            }
        });

        return web.app;
    });

from r.js.

jrburke avatar jrburke commented on May 27, 2024

For issue 1, if you clear/delete the built output then do a build, do the modules only show up once then? For what it is worth, the files should only appear once in the file. I'm having trouble figuring out a way to reproduce the problem. If you have a zip file of the contents I could try, feel free to send it to me privately. I'm jrburke on gmail too.

For issue 2, I was able to reproduce, thanks to your code sample. I pulled out the issue as issue #60 and there is a fix in there for it. You can try r-edge.js to verify that fix.

from r.js.

mailaneel avatar mailaneel commented on May 27, 2024

Event if i delete the output folder this is happening, And i also observed that i do not delete the output folder before doing a new build,
build is not correctly done.

As requested, i have sent an email

from r.js.

jrburke avatar jrburke commented on May 27, 2024

I looked more into this, and the problem is this: when the 'web.actionBar' module is optimized, it is written to disk with all of its dependencies inside it.This is done before the 'production' output is written to disk. The 'production' depends on 'web.actionBar' so when 'production' comes second in the list, it picks up the contents of the optimized web.actionBar, which includes the plugins.

So I did a fix to not write out the build layers to their final names until all the build layers have been written to disk at temporary names, then move them to their final position.

You can try r-edge.js to verify the fix. This will go into the 1.0.3 release.

Thank you very much for the test case.

from r.js.

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.