mirror of
https://github.com/flarum/core.git
synced 2025-05-25 16:50:25 +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:
parent
7fd61971d6
commit
49fa832a9b
@ -6,9 +6,5 @@ This package generates a [Webpack](https://webpack.js.org) config object that wi
|
|||||||
// webpack.config.js
|
// webpack.config.js
|
||||||
var config = require('flarum-webpack-config');
|
var config = require('flarum-webpack-config');
|
||||||
|
|
||||||
module.exports = config(options);
|
module.exports = config();
|
||||||
```
|
```
|
||||||
|
|
||||||
## Options
|
|
||||||
|
|
||||||
* `compatPrefix` Old-style module prefix (eg. `flarum/sticky`) to alias. Setting this will also enable importing old-style core modules (eg. `import foo from 'flarum/foo'`).
|
|
||||||
|
@ -34,28 +34,19 @@ module.exports = function(options = {}) {
|
|||||||
path.resolve(process.cwd(), 'node_modules'),
|
path.resolve(process.cwd(), 'node_modules'),
|
||||||
'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.
|
// Support importing old-style core modules.
|
||||||
config.externals = [
|
externals: [
|
||||||
function(context, request, callback) {
|
function(context, request, callback) {
|
||||||
let matches;
|
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] + '\']');
|
return callback(null, 'root flarum.compat[\'' + matches[1] + '\']');
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
];
|
]
|
||||||
}
|
};
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "flarum-webpack-config",
|
"name": "flarum-webpack-config",
|
||||||
"version": "0.1.0-beta.5",
|
"version": "0.1.0-beta.6",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"author": "Toby Zerner",
|
"author": "Toby Zerner",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user