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

webpack watch tarballs #86

Merged
merged 4 commits into from
Jul 3, 2024
Merged

webpack watch tarballs #86

merged 4 commits into from
Jul 3, 2024

Conversation

turbocrime
Copy link
Contributor

@turbocrime turbocrime commented Jul 3, 2024

improves local tarball workflow.

run

pnpm -w add /absolute/path/to/your/repo/*/namespace-tarballs-*.tgz
pnpm -w syncpack fix-mismatches
pnpm dev

in this repository to use local tarballs, and automatically reload changes when those tarballs update.

Copy link

changeset-bot bot commented Jul 3, 2024

⚠️ No Changeset found

Latest commit: cb26497

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@turbocrime turbocrime requested a review from TalDerei July 3, 2024 02:35
Copy link
Contributor

@TalDerei TalDerei left a comment

Choose a reason for hiding this comment

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

can you please restore watch-and-repack.sh? I've found it extremely useful for my workflow, and there's detailed instructions around using it. this can be an additional way to do local dev and keeping it doesn't hurt

let's also move it to the scripts folder so it's not in the root

@turbocrime turbocrime requested a review from TalDerei July 3, 2024 04:13
@turbocrime turbocrime changed the title dev-pack script webpack watch tarballs Jul 3, 2024
Copy link
Contributor

@TalDerei TalDerei left a comment

Choose a reason for hiding this comment

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

confirmed offline that script properly propagates changes.

general curiosity, what prevents it from falling into an infinite loop? when I simulated hmr with fswatch, it initially continuously triggered the repack process because the repack itself was causing changes that fswatch picked up, leading to an infinite loop.

@@ -147,10 +190,11 @@ const config: webpack.Configuration = {
filename: 'offscreen.html',
chunks: ['offscreen-handler'],
}),
// watch tarballs for changes
WEBPACK_WATCH && new WatchExternalFilesPlugin({ files: localPackages }),
WEBPACK_WATCH && PnpmInstallPlugin,
Copy link
Contributor

@TalDerei TalDerei Jul 3, 2024

Choose a reason for hiding this comment

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

I was aware of built-in dev hot module reloading config for webpack (https://webpack.js.org/configuration/watch/), but wasn't aware of the various watch options (https://webpack.js.org/configuration/watch/).

@turbocrime
Copy link
Contributor Author

general curiosity, what prevents it from falling into an infinite loop? when I simulated hmr with fswatch, it initially continuously triggered the repack process because the repack itself was causing changes that fswatch picked up, leading to an infinite loop.

You may have been fswatching files you were changing. This configuration only watches the tarballs, and it doesn't trigger any activity in the watched locations.

@turbocrime turbocrime merged commit bad78aa into main Jul 3, 2024
3 checks passed
@turbocrime turbocrime deleted the turbocrime/dev-pack branch July 3, 2024 06:35
@@ -2,6 +2,7 @@ import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react-swc';

export default defineConfig({
clearScreen: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this do?

Copy link
Contributor Author

@turbocrime turbocrime Jul 5, 2024

Choose a reason for hiding this comment

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

this prevents the marketing site vite build from blanking the terminal, so extension build output remains visible when running dev from the repository root

@@ -24,7 +23,7 @@
"noUnusedParameters": true,
"resolveJsonModule": true,
"target": "ESNext",
"module": "ES2022"
"module": "preserve"
Copy link
Contributor

Choose a reason for hiding this comment

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

what are the implications of this new module config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

there are zero implications because no packages are published from this repo. but due to several idiosyncratic configurations and webpack's lack of true support for typescript config, the previous module resolution prevented the import of the package json data in webpack config, and this resolution mode is more permissive.

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.

3 participants