Opened 9 years ago
Closed 8 years ago
#15146 closed defect (worksforme)
Missing dependency when building a module that contains context sensitive require
Reported by: | sprabhal | Owned by: | Rawld Gill |
---|---|---|---|
Priority: | high | Milestone: | 1.9 |
Component: | BuildSystem | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
When a module containing a context-sensitive require as mentioned in https://dojotoolkit.org/reference-guide/1.7/loader/amd.html#context-sensitive-require is built, it results in a missing dependency error during runtime. Everything works fine in the non-built version.
I did see a comment "require must not have relative mids" in util/build/transforms/depsScan.js. Does that mean context-sensitive require can never be built.
Change History (6)
comment:1 follow-up: 3 Changed 9 years ago by
Owner: | changed from Rawld Gill to sprabhal |
---|---|
Status: | new → pending |
comment:2 Changed 9 years ago by
Status: | pending → new |
---|
define([ "require", "dojo/_base/declare" ], function (require, declare) { return declare(null, { constructor: function () { //constructor }, foo: function () { require([ "./foo", "./bar" ], function (foo, bar) { var fooCopy = foo; var barCopy = bar; //some operation }); } }); });
comment:3 Changed 9 years ago by
define([ "require", "dojo/_base/declare" ], function (require, declare) { return declare(null, { constructor: function () { //constructor }, foo: function () { require([ "./foo", "./bar" ], function (foo, bar) { var fooCopy = foo; var barCopy = bar; //some operation }); } }); });
Replying to neonstalwart:
most likely you do not have
require
as a dependency in your moduledefine(['require'], function (require) { var foo = require('./foo'), bar = require('./bar'); // ... });can you provide a sample of the code that fails?
comment:4 Changed 8 years ago by
Milestone: | tbd → 1.9 |
---|---|
Priority: | undecided → high |
If this is still an issue, it's kind of a big one.
Can we review and fix for 1.9, if it's an issue?
comment:5 Changed 8 years ago by
Owner: | changed from sprabhal to Rawld Gill |
---|---|
Status: | new → assigned |
comment:6 Changed 8 years ago by
Resolution: | → worksforme |
---|---|
Status: | assigned → closed |
this is working as designed. using require that way is how you lazy-load other layers after a build. leaving those dependencies out is supposed to happen. if they need to be in the same layer then add them as dependencies in the call to define for this module.
most likely you do not have
require
as a dependency in your modulecan you provide a sample of the code that fails?