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

fix: Adding in missing getter for document.head #87

Merged
merged 2 commits into from
Nov 18, 2021
Merged

fix: Adding in missing getter for document.head #87

merged 2 commits into from
Nov 18, 2021

Conversation

rschristian
Copy link
Contributor

@rschristian rschristian commented Nov 9, 2021

Closes #69

Simply missing a getter for head.

Full stack trace of the error that this fixes. The one in the linked issue is fairly outdated and the error position is no longer correct:

TypeError: Cannot read property 'appendChild' of undefined
    at ../../node_modules/critters-webpack-plugin/dist/critters-webpack-plugin.js:199:23
        at Array.map (<anonymous>)
    at ../../node_modules/critters-webpack-plugin/dist/critters-webpack-plugin.js:195:24
        at Array.forEach (<anonymous>)
    at CrittersWebpackPlugin.embedAdditionalStylesheet (../../node_modules/critters-webpack-plugin/dist/critters-webpack-plugin.js:188:48)
    at CrittersWebpackPlugin.process (../../node_modules/critters/dist/critters.js:633:12)
    at handleHtmlPluginData (../../node_modules/critters-webpack-plugin/dist/critters-webpack-plugin.js:85:14)
    at eval (eval at create (../../node_modules/tapable/lib/HookCodeFactory.js:74:10), <anonymous>:13:1)
    at AsyncSeriesWaterfallHook.eval [as promise] (eval at create (../../node_modules/tapable/lib/HookCodeFactory.js:74:10), <anonymous>:2:8)
    at AsyncSeriesWaterfallHook.lazyCompileHook (../../node_modules/tapable/lib/Hook.js:154:20)
    at ../../node_modules/html-webpack-plugin/index.js:267:70

Adds a couple tests to ensure additionalStylesheets works.


document.body.appendChild(document.createTextNode('this counts as SSR'));

import('./chunk.js').then();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If there's a slightly less awkward way to create another chunk, certainly let me know. This was just to generate another stylesheet

Comment on lines +167 to +173
<style>html {
padding: 0px;
}

html {
padding: 0px;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately this is correct at the moment, and Critters no longer dedupes, see #88

@rschristian
Copy link
Contributor Author

@developit Sorry to ping, but any chance you could take a look at this? This is the only remaining blocker for upgrading to HtmlWebpack v4 in preact-cli

@developit developit merged commit 24284db into GoogleChromeLabs:main Nov 18, 2021
@developit
Copy link
Collaborator

@rschristian published as critters@0.0.15!

@rschristian
Copy link
Contributor Author

Thanks!

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.

Refactor: additionalStylesheets appears broken
3 participants