Closed linonetwo closed 3 years ago
Seems setting https://webpack.js.org/configuration/externals/ is not working, the package is still being inlined. not required.
if I use
new webpack.IgnorePlugin({ resourceRegExp: /@tiddlygit\/tiddlywiki/ }),
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
new ThreadsPlugin({ target: 'electron-node-worker', plugins: [new webpack.IgnorePlugin({ resourceRegExp: /@tiddlygit\/tiddlywiki/ })] }),
it will be webpackMissingModule
!(function webpackMissingModule() { var e = new Error("Cannot find module '@tiddlygit/tiddlywiki'"); e.code = 'MODULE_NOT_FOUND'; throw e; }());
I tried https://github.com/andywer/threads-plugin/issues/19 and it is not working anymore in webpack4.
Finally use:
new ExternalsPlugin({
type: 'commonjs',
include: path.join(__dirname, 'node_modules'),
}),
new ThreadsPlugin({
target: 'electron-node-worker',
plugins: ['ExternalsPlugin'],
}),
I can see all required files are inline into
0.index.worker.js
But this seem to causes error on
path.dirname(module.filename);
it saysmodule.filename
is undefined.I log the module, it is
And I think it will break
path.resolve($tw.boot.bootPath,"../core")
So I think if we keep
@tiddlygit/tiddlywiki
to berequire('@tiddlygit/tiddlywiki')
instead of inline it, it will works fine.