fied require problem in webpacked app

This commit is contained in:
Jan Prochazka
2020-11-26 15:42:50 +01:00
parent d7ceb297e9
commit 3533683a32
5 changed files with 28 additions and 400 deletions

View File

@@ -1,21 +0,0 @@
module.exports = {
env: {
node: true,
commonjs: true,
es6: true,
jquery: false,
jest: true,
jasmine: true,
},
extends: 'eslint:recommended',
globals: {
Atomics: 'readonly',
SharedArrayBuffer: 'readonly',
},
parserOptions: {
ecmaVersion: 2018,
},
rules: {
'no-unused-vars': 'warn',
},
};

View File

@@ -12,8 +12,16 @@ function requirePlugin(packageName, requiredPlugin = null) {
if (loadedPlugins[packageName]) return loadedPlugins[packageName];
if (requiredPlugin == null) {
console.log('Loading module', packageName);
const module = require(path.join(pluginsdir(), packageName, 'dist', 'backend.js'));
let module;
const modulePath = path.join(pluginsdir(), packageName, 'dist', 'backend.js');
console.log(`Loading module ${packageName} from ${modulePath}`);
try {
// @ts-ignore
module = __non_webpack_require__(modulePath);
} catch (err) {
console.error('Failed load webpacked module', err);
module = require(modulePath);
}
requiredPlugin = module.__esModule ? module.default : module;
}
loadedPlugins[packageName] = requiredPlugin;

View File

@@ -14,9 +14,9 @@ var config = {
libraryTarget: 'commonjs2',
},
optimization: {
minimize: false,
},
// optimization: {
// minimize: false,
// },
// module: {
// rules: [
@@ -29,7 +29,7 @@ var config = {
plugins: [
new webpack.IgnorePlugin({
checkResource(resource) {
const lazyImports = ['pg-native', 'uws'];
const lazyImports = ['uws'];
if (!lazyImports.includes(resource)) {
return false;
}