Skip to content

Webpack5 comments#7450

Closed
zoran995 wants to merge 108 commits into
TerriaJS:webpack5from
zoran995:webpack5-comments
Closed

Webpack5 comments#7450
zoran995 wants to merge 108 commits into
TerriaJS:webpack5from
zoran995:webpack5-comments

Conversation

@zoran995

Copy link
Copy Markdown
Collaborator

What this PR does

Test me

Locally:

  • sync terriamap-terriajs dependencies
  • install dependencies
  • run the project
  • check that everything works the same (type checking is still working, assimpjs works correctly (copy-plugin-webpack))

Checklist

  • There are unit tests to verify my changes are correct or unit tests aren't applicable (if so, write quick reason why unit tests don't exist)
  • I've updated relevant documentation in doc/.
  • I've updated CHANGES.md with what I changed.
  • I've provided instructions in the PR description on how to test this PR.

tephenavies and others added 30 commits February 26, 2023 15:30
The eslint-recommended configuration
is a subset of recommended, so switch
to the recommended configuration and
remove the rules that are already part
of the recommended configuration.
There are a few rules that result in
numerous errors, so disable them for
now.
Remove the dark-matter image
now that it is no longer
referenced in the tests.

This should have been a part
of TerriaJS#7314.
Traverse the file system once,
and keep that result in a variable.
Replace the in-file var declarations with
let/const. Leave the imports as-is to avoid
conflicts with the CJS to ESM upgrade.
I got this warning when running
some command:

npm warn deprecated inflight@1.0.6: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.

and inflight is a dependency of glob,
which glob-all depends on. So replace
glob-all with fast-glob that both seems
fast and is already used by some other
dependencies.
This was previously used for loading polyfills from polyfill.io then we switched to core-js.
This saves the compiler the effort of
having to infer the types during
compilation, which shortens compilation
times.

This commit is just the code fixes, but
there is also a typescript-eslint
rule for this:

https://typescript-eslint.io/rules/explicit-module-boundary-types/

The annotations were generated from
the fixes in the TypeScript compiler
with:

ts-fix -t ./tsconfig-node.json -e 9008 --write --ignoreGitStatus --file lib/**/*.ts
These functions do not await anything,
so remove the async from them.

This will become an error when switching
to the typed lint rules in typescript-eslint.
To avoid breaking change to terriamap. We'll make this change
when upgrading to webpack5.
Move release guide to separate file
composes: btn from "../../../../Sass/common/_buttons.scss";
// TODO: fix?
// composes: btn-small from "../../../../Sass/common/_buttons.scss";
// composes: btn--left from "../../../../Sass/common/_buttons.scss";

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

btn--left was an icon definition so it is safe to remove
btn-small wouldn't make any point here as we have all its styles defined/overriden here or in styled-component

}

// TODO: fix?
// .btn-small {

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is not used anywhere anymore

Comment thread package.json
"engines": {
"node": ">= 16.0.0"
},
"sideEffects": false,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is apparently important for tree shaking. There is a granular version of sideEffects where you provide paths, and I think that would make sense since there are so few imports with side effects in the tree currently. Long-term, I'm guessing you want to get rid of side effecting imports.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is not always easy to properly setup the list of files, and I don't want to block the webpack upgrade with that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

True, it's already been sitting for 2 months, would be nice to get these big PRs into main.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yeah, we should remove this setting. I was mostly testing to see if it broke anything - it doesn't seem to. I think we can revisit this later.

@pjonsson

pjonsson commented Feb 6, 2025

Copy link
Copy Markdown
Contributor

Your change to that other package looks straightforward and should be a matter of just merging, and then getting this moving. Do you know what is blocking the progress with getting this merged?

The diff view is no longer useful for reviewing after merging main, but besides me wishing for not completely eliminating the sideEffects directive I think what was here before merging main into the PR looked good.

Comment thread lib/ReactViews/Notification/NotificationWindow.jsx
@zoran995 zoran995 requested review from ljowen and na9da February 7, 2025 21:49
@zoran995

zoran995 commented Feb 7, 2025

Copy link
Copy Markdown
Collaborator Author

@na9da I had to restore worker-loader as webpack native web worker support tends to get pretty complex, I will keep looking for a fix but it might be good to keep worker-loader and handle that as a follow-up
p. S. Important note: webpack worker support behaves differently in development and production builds. That's why it works on CI but fails locally. I have run into this issue in the past but still don't have a solution that always works

new URL("./downloadHrefWorker.js", import.meta.url)
);
const worker = await import(
//@ts-expect-error: aaa

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I assume you know the reason you had to put this ts-expect-error in, put that instead of "aaa".

And style wise, no other ts-expect-error in terriajs has a colon after it, and most of them have a space between the // and @ts-expect-error.

@pjonsson

pjonsson commented Feb 8, 2025

Copy link
Copy Markdown
Contributor

p. S. Important note: it behaves differently in development and production builds with native support. That's why it works on CI but fails locally.

I don't know what part of the code this concerns, but it seems worth to put a comment in the code at that place so it doesn't get missed/lost the next time that thing is upgraded.

@zoran995

Copy link
Copy Markdown
Collaborator Author

I have cherry-picked and merged all changes from here into #7351, so it is easier and faster to review
Closing this

@zoran995 zoran995 closed this Feb 10, 2025
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

Successfully merging this pull request may close these issues.

8 participants