mirror of
https://github.com/flarum/core.git
synced 2025-08-06 16:36:47 +02:00
Remove compatPrefix
option
Aliasing was only working for the `src` directory, it would not find modules in the `lib` directory. Therefore the easiest way to migrate will be to remove the prefix manually from import statements.
This commit is contained in:
@@ -34,28 +34,19 @@ module.exports = function(options = {}) {
|
||||
path.resolve(process.cwd(), 'node_modules'),
|
||||
'node_modules'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
if (options.compatPrefix) {
|
||||
// Strip the old-style module prefix from non-relative-path imports by
|
||||
// aliasing it to nothing.
|
||||
config.resolve = config.resolve || {};
|
||||
config.resolve.alias = {
|
||||
[options.compatPrefix]: '.'
|
||||
};
|
||||
},
|
||||
|
||||
// Support importing old-style core modules.
|
||||
config.externals = [
|
||||
externals: [
|
||||
function(context, request, callback) {
|
||||
let matches;
|
||||
if ((matches = /^flarum\/(.+)$/.exec(request)) && request.substr(0, options.compatPrefix.length) !== options.compatPrefix) {
|
||||
if ((matches = /^flarum\/(.+)$/.exec(request))) {
|
||||
return callback(null, 'root flarum.compat[\'' + matches[1] + '\']');
|
||||
}
|
||||
callback();
|
||||
}
|
||||
];
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
return config;
|
||||
};
|
||||
|
Reference in New Issue
Block a user