Skip to content

application-manager: use Webpack v5#9451

Merged
paul-marechal merged 1 commit intomasterfrom
mp/webpack5
May 13, 2021
Merged

application-manager: use Webpack v5#9451
paul-marechal merged 1 commit intomasterfrom
mp/webpack5

Conversation

@paul-marechal
Copy link
Member

Bump Webpack from 4 to 5 and update the generated configurations to use
the new APIs.

Closes #9435

How to test

Only impacts the browser/electron-browser, everything should work like before.

  • Images and icons should be properly loaded.
  • Monaco editor should be working.
  • WASM should be loaded (if not syntax highlighting won't work properly)

Review checklist

Reminder for reviewers

@paul-marechal
Copy link
Member Author

cc @eclipse-theia/core

@paul-marechal paul-marechal added dependencies issues that plan to update dependencies enhancement issues that are enhancements to current functionality - nice to haves labels May 7, 2021
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified the following for both browser and electron targets:

  • icons are loaded successfully.
  • fonts are loaded successfully.
  • syntax-highlighting works correctly.

I also verified that the updated dependencies are license compatible (through clearly defined).

I'll let other review as well 👍

@msujew
Copy link
Member

msujew commented May 11, 2021

LGTM, I can confirm that everything works as expected in the browser and electron targets.

Furthermore, this change reduces the size of the webpack bundles by a few hundred KB and the node_modules directory by about 80MB 👍

@paul-marechal
Copy link
Member Author

paul-marechal commented May 13, 2021

Thanks for the reviews. Since the reference to process.env got removed from the frontend code on master I changed the configs here to not deal with that anymore. Will merge tomorrow.

Bump Webpack from 4 to 5 and update the generated configurations to use
the new APIs.

Some packages are no longer required as Webpack provides similar features
now, see https://webpack.js.org/guides/asset-modules/.

On the other hand, Webpack doesn't provide some of the shims it used to.
We need to setup some of those ourselves. The frontend entrypoint now
requires `setimmediate` to shim the `setImmediate` APIs, and we use
Webpack's `ProvidePlugin` to expose Node's `Buffer` API for our
dependencies to work.
"setimmediate": "^1.0.5",
"source-map-loader": "^2.0.1",
"source-map-support": "^0.5.19",
"style-loader": "^2.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paul-marechal One thing I still don't understand here is why these are not in the devDependencies section. Does webpack not take care of including them in the mangled output?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

devDependencies are not installed when a package is depended upon meaning those packages would be missing for dependents. Hence those being regular dependencies.

Regarding the bundling, setimmediate is required in src-gen and bundled. The loaders should never reach the final bundles, although they need to be in the environment used to run Webpack (using Theia CLI.)

Copy link
Member Author

@paul-marechal paul-marechal Aug 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking about it, if @theia/application-manager only appears as a dev-dependency in a application package.json it should keep working indeed. But from the POV of @theia/application-manager these dependencies must be pulled alongside it, so they can't be declared as devDependencies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, so the correct way to consume all that is to have @theia/application-manager as a dev dependency in the application package (like examples/browser)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Experimenting a bit further with this: unless I add an explicit dependency in my application to stuff like circular-dependency-plugin only gets installed into node_modules/@theia/application-manager/node_modules/circular-dependency-plugin and thus is not available for require(...)from gen-weback-config.js. So I think we need to fix https://theia-ide.org/docs/composing_applications.

Copy link
Member Author

@paul-marechal paul-marechal Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you describe sounds like a hoisting problem and it can be painful to troubleshoot. It is part of why I wanted to limit implicit dependencies as much as possible. In this specific case I am not sure how you could dedup the package. yarn why can be useful to see all dependents, and if every package depends on the same version yarn should install it only once at the root of your node_modules.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you folks build your application packages? Do you consume the theia packages as npm modules?

Copy link
Member Author

@paul-marechal paul-marechal Aug 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you consume the theia packages as npm modules?

Most of the time yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies issues that plan to update dependencies enhancement issues that are enhancements to current functionality - nice to haves

Projects

None yet

Development

Successfully merging this pull request may close these issues.

upgrade to Webpack v5

4 participants