Changing requirejs baseUrl has side-effects
See original GitHub issueI’m submitting a bug report (but I’m not entirely sure if this is a bug or intended)
- Library Version: 0.21.0
Please tell us about your environment:
-
Operating System: Windows 8
-
Node Version: 6.2.2
-
NPM Version: 3.10.5
-
Browser: all
-
Language: all
Current behavior:
According to the documentation we can set requirejs
config settings. I’ve tried to set this:
"baseUrl": "scripts/"
The reason for this is I’d like to dynamically load some components (aka “plugins”) which are not bundled. I’d like to have these components in scripts/plugins/
. If I don’t change the baseUrl, the bundle tries to load these plugins from src/plugins
, which will not be available on a production server.
If I do change the baseUrl, the module ids are generated to be relative to scripts
, so for instance main.js
is bundled like this:
define('../src/main', ...
This leads to the bootstrapper not finding any aurelia libs or the main entry point of the app.
Other files are bundled with the same prefix (../src/
).
Without this change, requirejs modules are defined like this:
define('main', ...
Expected/desired behavior:
- What is the expected behavior?
In my opinion, setting requirejs
baseUrl should only affect the requirejs
configuration in vendor-bundle.js
.
In other words:
If I change this manually in vendor-bundle.js
it works as I expect it. Files are bundled correctly and plugins are loaded from scripts/plugins
.
I will upload a reproduction repo in a few minutes.
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (8 by maintainers)
BTW, I recall when I uses cli-bundler yrs before, I did use gulp-replace to touch the
vendor-bundle.js
, just replace"baseUrl": "src"
to"baseUrl": REQUIREJS_BASE_URL
.I then have the global var set in html file like this
<script>var REQUIREJS_BASE_URL="/scripts";</script>
which is easy for me to control.BTW, dumber supported that global var by default. Here is the generated skeleton from dumber:
@3cp awesome!!