This article has helped me setup an environment for developing non-core modules (haven’t tried with core modules):
My exemple features a plugin I’m working on which is called aurelia-resources
. My folders are like this:
.../aurelia-resources <- with my plugin
.../a-webpack-aurelia-app <- with an app created with CLI
From the webpack-aurelia-app I do:
npm link ../aurelia-resources
.
Out of the box this doesn’t work. But following the advices in the mentioned article, I’ve edited the webpack.config.js
file like so:
module.exports = ({production, server, extractCss, coverage, analyze} = {}) => ({
resolve: {
extensions: ['.ts', '.js'],
modules: [srcDir, 'node_modules'],
symlinks: false,
alias: {
'@aurelia-ux/core': path.resolve('./node_modules/@aurelia-ux/core'),
'aurelia-binding': path.resolve('./node_modules/aurelia-binding'),
'aurelia-bootstraper': path.resolve('./node_modules/aurelia-bootstraper'),
'aurelia-dependency-injection': path.resolve('./node_modules/aurelia-dependency-injection'),
'aurelia-event-aggregator': path.resolve('./node_modules/aurelia-event-aggregator'),
'aurelia-fetch-client': path.resolve('./node_modules/aurelia-fetch-client'),
'aurelia-framework': path.resolve('./node_modules/aurelia-framework'),
'aurelia-history': path.resolve('./node_modules/aurelia-history'),
'aurelia-history-browser': path.resolve('./node_modules/aurelia-history-browser'),
'aurelia-loader': path.resolve('./node_modules/aurelia-loader'),
'aurelia-loader-default': path.resolve('./node_modules/aurelia-loader-default'),
'aurelia-loader-nodejs': path.resolve('./node_modules/aurelia-loader-nodejs'),
'aurelia-logging': path.resolve('./node_modules/aurelia-logging'),
'aurelia-logging-console': path.resolve('./node_modules/aurelia-logging-console'),
'aurelia-metadata': path.resolve('./node_modules/aurelia-metadata'),
'aurelia-pal': path.resolve('./node_modules/aurelia-pal'),
'aurelia-pal-browser': path.resolve('./node_modules/aurelia-pal-browser'),
'aurelia-pal-nodejs': path.resolve('./node_modules/aurelia-pal-nodejs'),
'aurelia-path': path.resolve('./node_modules/aurelia-path'),
'aurelia-polyfills': path.resolve('./node_modules/aurelia-polyfills'),
'aurelia-route-recognizer': path.resolve('./node_modules/aurelia-route-recognizer'),
'aurelia-router': path.resolve('./node_modules/aurelia-router'),
'aurelia-task-queue': path.resolve('./node_modules/aurelia-task-queue'),
'aurelia-templating': path.resolve('./node_modules/aurelia-templating'),
'aurelia-templating-binding': path.resolve('./node_modules/aurelia-templating-binding'),
'aurelia-templating-resources': path.resolve('./node_modules/aurelia-templating-resources'),
'aurelia-testing': path.resolve('./node_modules/aurelia-testing')
}
},
with the symlinks: false
that ensure the link with npm link
and alias: {...}
properties which helps webpack resolve the concurrent dependencies from the right directory.
The pain is to write all the correct aliases. But once this is done, any changes in the plugin is reflected (in watch
mode) inside the app and development becomes a lot more enjoyable.