fix: graphics on server

This commit is contained in:
cha0s 2021-03-23 00:37:43 -05:00
parent 5d322460d3
commit eb6309f11f
6 changed files with 54 additions and 9 deletions

View File

@ -4,15 +4,16 @@ module.exports = require('@latus/build/build/.neutrinorc.js');
const code = [
"if ('client' !== process.env.SIDE) {",
"('undefined' !== typeof __non_webpack_require__ ? __non_webpack_require__ : require)('pirates').addHook(",
"(code, filename) => '',",
"{",
"ignoreNodeModules: false,",
"matcher: (filename) => filename.match('@pixi')",
"}",
")",
" // eslint-disable-next-line no-eval",
" eval('require')('pirates').addHook(",
" () => '',",
" {",
" ignoreNodeModules: false,",
" matcher: (filename) => filename.match('@pixi'),",
" },",
" );",
"}",
].join('');
].join('\n');
module.exports.use.push(banner({
banner: code,

View File

@ -26,6 +26,7 @@
"@avocado/traits": "^2.0.0",
"@latus/core": "^2.0.0",
"@latus/socket": "2.0.0",
"@neutrinojs/banner": "^9.5.0",
"@pixi/constants": "^5.3.6",
"@pixi/core": "^5.3.6",
"@pixi/display": "^5.3.6",

View File

@ -0,0 +1,38 @@
const banner = require('@neutrinojs/banner');
module.exports = (server) => {
server.use.unshift((neutrino) => {
[
'@pixi/constants$',
'@pixi/core$',
'@pixi/display$',
'@pixi/filter-adjustment$',
'@pixi/filter-advanced-bloom$',
'@pixi/filter-color-matrix$',
'@pixi/filter-glow$',
'@pixi/graphics$',
'@pixi/math$',
'@pixi/settings$',
'@pixi/sprite$',
'@pixi/text$',
].forEach((path) => {
neutrino.config.resolve.alias
// eslint-disable-next-line no-eval
.set(path, eval('require').resolve('@latus/core'));
});
});
const code = [
'// eslint-disable-next-line no-eval',
'eval(\'require\')(\'pirates\').addHook(',
' () => \'\',',
' {',
' ignoreNodeModules: false,',
' matcher: (filename) => filename.match(\'@pixi\'),',
' },',
');',
].join('\n');
server.use.unshift(banner({
banner: code,
pluginId: 'pixi-stub-banner',
}));
};

View File

@ -1,5 +1,7 @@
import {gatherWithLatus} from '@latus/core';
import build from './build';
export {default as Canvas} from './canvas';
export {default as Color} from './color';
export {default as Container} from './container';
@ -32,6 +34,9 @@ export default {
'@avocado/traits/traits': gatherWithLatus(
require.context('./traits', false, /\.js$/),
),
'@latus/core/build': ({server}) => {
build(server);
},
'@latus/socket/packets': gatherWithLatus(
require.context('./packets', false, /\.js$/),
),

View File

View File

@ -1082,7 +1082,7 @@
eslint-plugin-react "^7.21.5"
eslint-plugin-react-hooks "^4.2.0"
"@neutrinojs/banner@^9.4.0":
"@neutrinojs/banner@^9.4.0", "@neutrinojs/banner@^9.5.0":
version "9.5.0"
resolved "http://npm.cha0sdev/@neutrinojs%2fbanner/-/banner-9.5.0.tgz#ee8df39db5d76033211a1811428e444a06d7222f"
integrity sha512-SL4nT0V1Wykf+LcRlCp/L8Frt4dk7MZITToC+OeDz2w6V7gg8YfEwDfdEg+aampjyUoxaq+A02ZyZP1TyRDtLA==