Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"./prerender": "./src/prerender.js",
"./hydrate": "./src/hydrate.js"
},
"sideEffects": false,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am not sure this is safe everywhere, we might need to do a if (!initialized) registerOptionsHooks() in the relevant components

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

How so?

The only issue I can see is if the user is using the <Router> as an implicit suspense boundary without ever using lazy() (or ErrorBoundary) -- this is a very unlikely scenario, given suspense's low usage, nor do I think it's one we should support by injecting more code than actually asked for or needed.

As for normal usage, every modern bundler will see the side-effectful usage within individual modules and keep the hooks around if the module as a whole is ever loaded, i.e., if the user ever imports lazy or ErrorBoundary. I don't know how non-modern bundlers act here but I don't think we need to be preemptively concerned.

I don't foresee anything else being problematic here, but perhaps I'm missing something?

"license": "MIT",
"description": "Isomorphic utilities for Preact",
"author": "The Preact Authors (https://preactjs.com)",
Expand Down
Loading