mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
修复 salsprep 不能正确被 webpack 打包的问题
This commit is contained in:
1 parent
c389d20c51
commit
cd6938dd6c
3 files changed
+15
-5
No files matched your search
@@ -1,4 +1,5 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
formidable: () => {
|
||||
@@ -34,4 +35,17 @@ module.exports = {
|
||||
console.error('Cannot hack yargs');
|
||||
}
|
||||
},
|
||||
saslprep: () => {
|
||||
const q = require.resolve('saslprep');
|
||||
const mem = path.join(path.dirname(q), 'code-points.mem');
|
||||
const p = path.join(path.dirname(q), 'lib', 'memory-code-points.js');
|
||||
const data = fs.readFileSync(mem);
|
||||
const file = fs.readFileSync(p).toString().split('\n');
|
||||
if (file[7].includes('fs.readFileSync')) {
|
||||
file[7] = `const memory = Buffer.from('${data.toString('base64')}', 'base64');`;
|
||||
fs.writeFileSync(p, file.join('\n'));
|
||||
} else if (!file[7].includes('Buffer.from')) {
|
||||
console.error('Cannot hack saslprep');
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable import/no-extraneous-dependencies */
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const FriendlyErrorsPlugin = require('friendly-errors-webpack-plugin');
|
||||
const { root } = require('./utils');
|
||||
@@ -21,9 +20,6 @@ const build = async (type) => {
|
||||
new FriendlyErrorsPlugin({
|
||||
clearConsole: false,
|
||||
}),
|
||||
new webpack.ProvidePlugin({
|
||||
saslprep: path.resolve(__dirname, 'node_modules/saslprep/index.js'),
|
||||
}),
|
||||
],
|
||||
};
|
||||
const compiler = webpack(config);
|
||||
|
||||
@@ -662,5 +662,5 @@ export async function start() {
|
||||
}
|
||||
|
||||
global.Hydro.service.server = {
|
||||
param, Handler, ConnectionHandler, Route, Connection, Middleware, prepare, start,
|
||||
Types, param, Handler, ConnectionHandler, Route, Connection, Middleware, prepare, start,
|
||||
};
|
||||
Reference in new issue
Block a user