Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#8325 closed enhancement (wontfix)

enhanced layer support (integrated with package system)

Reported by: Mike Wilson Owned by: James Burke
Priority: high Milestone: tbd
Component: BuildSystem Version: 1.2.3
Keywords: Cc:
Blocked By: Blocking:

Description

It would be great if the build system could treat layers as "first class citizens" and work together with the package system to make them transparent to code in modules. Below is a suggestion on how that could be done.

  1. While building layers in my custom build, the build system records what modules go in each layer:
    dojo.js: ["dojo.a","dojo.b"]
    mydojocore.js: ["dojo.c","dojo.d"]
    mydijit.js: ["dijit.e","dijit.f"]
    
  1. Then this information is included as a layer lookup map in my custom built dojo.js like this:
    {
      "dojo.a": "dojo.js",
      ...
      "dojo.c": "mydojocore.js",
      ...
    }
    
  1. Then, at runtime, dojo.require() checks with the layer map before bringing in a module, and loads the layer file instead when applicable.

The result is that code that calls dojo.require("dojo.c") will transparently bring in "mydojocore.js" instead of "dojo/c.js".

(Maybe some additional tweaks could even add support for custom base builds so a layer with "the rest of base" is automatically loaded when requiring something outside base.)

Best regards Mike Wilson

Change History (2)

comment:1 Changed 11 years ago by James Burke

Resolution: wontfix
Status: newclosed

I prefer the approach of creating a JS file (say foo/bar.js) that dojo.requires all the things you want in the layer, and then you reference dojo.require("foo.bar") in your code and in the build layer, create a layer for foo/bar.js and its only dependency is "foo.bar".

This allows you to not have to change your code after doing a build, and it still maps to the normal module.name pattern we have, instead of using a layer name that does not really translate to something that can be dojo.required.

If we could do it over again I would almost prefer that we not allow layer names that do not actually map to file on disk in the build profiles. Then, to specify a layer, you would just specify the resource name ("foo.bar" in the above example). Maybe something for Dojo 2.0.

So in summary I prefer encouraging making a wrapper module file rather than changing the build system to embed knowledge of the layers. I believe it will cause problems to embed file paths associated with resource names: normally that resource name to file mapping is only done via modulePaths/baseUrl functionality and I would prefer to limit the name-to-path resolution paths.

Closing out as wontfix, but feel free to reopen if you have more information.

comment:2 Changed 11 years ago by Mike Wilson

(I'm moving the discussion to the mailing list; in retrospect that's really where I should have put it from the start I guess.)

Note: See TracTickets for help on using tickets.