Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to not inline files #41

Closed
linonetwo opened this issue May 3, 2021 · 2 comments
Closed

Option to not inline files #41

linonetwo opened this issue May 3, 2021 · 2 comments

Comments

@linonetwo
Copy link

linonetwo commented May 3, 2021

I can see all required files are inline into 0.index.worker.js

/***/ "./node_modules/@tiddlygit/tiddlywiki/boot sync recursive":
/*!******************************************************!*\
  !*** ./node_modules/@tiddlygit/tiddlywiki/boot sync ***!
  \******************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
		$tw.boot.bootPath = options.bootPath || path.dirname(module.filename);
		$tw.boot.corePath = path.resolve($tw.boot.bootPath,"../core");

But this seem to causes error on path.dirname(module.filename); it says module.filename is undefined.

I log the module, it is

{
  i: './node_modules/@tiddlygit/tiddlywiki/boot/boot.js',
  l: true,
  exports: { TiddlyWiki: [Function: _boot] },
  deprecate: [Function (anonymous)],
  paths: [],
  children: [],
  loaded: [Getter],
  id: [Getter],
  webpackPolyfill: 1
}

And I think it will break path.resolve($tw.boot.bootPath,"../core")

So I think if we keep @tiddlygit/tiddlywiki to be require('@tiddlygit/tiddlywiki') instead of inline it, it will works fine.

@linonetwo
Copy link
Author

linonetwo commented May 3, 2021

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 #19 and it is not working anymore in webpack4.

@linonetwo
Copy link
Author

Finally use:

  new ExternalsPlugin({
    type: 'commonjs',
    include: path.join(__dirname, 'node_modules'),
  }),
  new ThreadsPlugin({
    target: 'electron-node-worker',
    plugins: ['ExternalsPlugin'],
  }),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant