mirror of
https://github.com/flarum/core.git
synced 2025-08-06 08:27:42 +02:00
feat: export registry (#3842)
* feat: registry first iteration Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * feat: improve webpack auto export loader Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * chore: remove `compat` API Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> * chore: cleanup Signed-off-by: Sami Mazouz <sychocouldy@gmail.com> --------- Signed-off-by: Sami Mazouz <sychocouldy@gmail.com>
This commit is contained in:
48
js-packages/webpack-config/tests/compiler.js
Normal file
48
js-packages/webpack-config/tests/compiler.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import path from 'path';
|
||||
import webpack from 'webpack';
|
||||
import { createFsFromVolume, Volume } from 'memfs';
|
||||
import * as fs from 'fs';
|
||||
|
||||
export default (fixture, options = {}) => {
|
||||
const compiler = webpack({
|
||||
context: __dirname,
|
||||
entry: `./${fixture}`,
|
||||
output: {
|
||||
path: path.resolve(__dirname),
|
||||
filename: 'bundle.js',
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
use: {
|
||||
loader: path.resolve(__dirname, '../src/autoExportLoader.cjs'),
|
||||
options: {
|
||||
...options,
|
||||
composerPath: '../../composer.json',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
optimization: {
|
||||
minimize: false,
|
||||
minimizer: [],
|
||||
},
|
||||
});
|
||||
|
||||
compiler.outputFileSystem = createFsFromVolume(new Volume());
|
||||
compiler.outputFileSystem.join = path.join.bind(path);
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
compiler.run((err, stats) => {
|
||||
if (err) reject(err);
|
||||
if (stats.hasErrors()) reject(stats.toJson().errors);
|
||||
|
||||
const outputFilepath = path.join(compiler.options.output.path, compiler.options.output.filename);
|
||||
stats.finalOutput = compiler.outputFileSystem.readFileSync(outputFilepath, 'utf-8');
|
||||
|
||||
resolve(stats);
|
||||
});
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user