Opened 6 years ago

Closed 6 years ago

#16403 closed defect (worksforme)

Incorrect require.toUrl computation

Reported by: JMelnik Owned by: Rawld Gill
Priority: undecided Milestone: 1.9
Component: Loader Version: 1.8.1
Keywords: Cc:
Blocked By: Blocking:

Description

When requiring AMD module using require, it generates url to require using require.toUrl function. When having custom package for sources and baseUrl defined, the generated URL is incorrect.

Given an example:
Project tree:

dojo
dojox
dijit
util
app (contains package build scripts app.profile.js)
release.profile.js (application build script)

After, building dojo using release.profile.js, everything builds fine and works fine.

Using Opera 11.50 and invoking from console:

dojo.config.baseUrl = '/path/to/scripts';
require.toUrl("app/A");

Expected behavior:

Generated url: path/to/scripts/app/A

Actual behavior:

Generated url: path/to/app/A

Analysis:
I looked at require.toUrl function, and I saw, that require.packs contains objects describing packages and their locations:

dojo.location = '.';
dojox.location = '../dojox';
dijit.location = '../dijit';
app.location = '../app';

When concating baseUrl '/path/to/scripts/' with mid 'app/A', it replaces 'app' with '../app' from require.packs element, thus it goes one directory back.

Attachments (1)

eg-16403.zip (1.3 KB) - added by Rawld Gill 6 years ago.
example that goes with comment 2

Download all attachments as: .zip

Change History (3)

comment:1 Changed 6 years ago by bill

Component: GeneralLoader
Owner: set to Rawld Gill

comment:2 Changed 6 years ago by Rawld Gill

Milestone: tbd1.9
Resolution: worksforme
Status: newclosed

I can't duplicate this report. I've attached an example of a minimal package with a build script that shows everything is working correctly. If you unzip the attachment to the parent of the dojo directory (i.e., so that the myPackage tree is a sibling of dojo, digit, et al...just as you report) and do a build from the util/buildscripts directory with the command

./build.sh -p ../../release.profile.js -r --layerOptimize 0 --optimize 0

and run t.html, you should see output as expected.

Changed 6 years ago by Rawld Gill

Attachment: eg-16403.zip added

example that goes with comment 2

Note: See TracTickets for help on using tickets.