I'm submitting a bug report
Please tell us about your environment:
Current behavior:
When using .plugin(PLATFORM.moduleName('my/plugin/path')) on a production build, where ModuleConcatenationPlugin runs by default, the module ends up on the bundle with the key my/plugin/path/index, so the app fails to run as my/plugin/path doesn't exist.
Expected/desired behavior:
On the main configure of the app, use .plugin for a local folder index file that includes a component/service/valueConverter, basically anything that the ModuleConcatenationPlugin may want to optimize:
// main.js
export const configure = (aurelia) => {
aurelia.use
.plugin(PLATFORM.moduleName('modules/my-module'))
.standardConfiguration();
return aurelia.start().then(() => aurelia.setRoot(...));
};
// modules/my-module/index.js
import { MY_CONSTANT } = './my-constant.js';
export const configure = (aurelia) => {
console.log(MY_CONSTANT);
};
// modules/my-module/my-constant.js
export const MY_CONSTANT = {
someKey: 'someValue',
};
That's enough for ModuleConcatenationPlugin to try to put my-constant inside my-module/index.js and for the PreserveModuleNamePlugin to change modules/my-module to modules/my-module/index.
- What is the expected behavior?
For PreserveModuleNamePlugin not to add the /index.
Not sure if this is the right way to do it, but if we add the following code before this line, it works:
if (id.endsWith('/index') && !realModule.rawRequest.endsWith('index')) {
id = id.replace(/\/index$/, '');
// or id = id.substr(0, id.length - 6);
}
I'm not that familiar with the module structure, so I'm not sure if we can "trust" in rawRequest
I'm submitting a bug report
3.0.0
Please tell us about your environment:
Operating System:
OSX 10.13.6
Node Version:
10.15.3
NPM Version:
6.4.1
JSPM OR Webpack AND Version
webpack 4.29.1
Browser:
all
Language:
ESNext
Current behavior:
When using
.plugin(PLATFORM.moduleName('my/plugin/path'))on a production build, whereModuleConcatenationPluginruns by default, the module ends up on the bundle with the keymy/plugin/path/index, so the app fails to run asmy/plugin/pathdoesn't exist.Expected/desired behavior:
On the main
configureof the app, use.pluginfor a local folder index file that includes a component/service/valueConverter, basically anything that theModuleConcatenationPluginmay want to optimize:That's enough for
ModuleConcatenationPluginto try to putmy-constantinsidemy-module/index.jsand for thePreserveModuleNamePluginto changemodules/my-moduletomodules/my-module/index.For
PreserveModuleNamePluginnot to add the/index.Not sure if this is the right way to do it, but if we add the following code before this line, it works:
I'm not that familiar with the module structure, so I'm not sure if we can "trust" in
rawRequest