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

Fixes #251 closing the parent tag if the component rendering led to a… #283

Closed

Conversation

ewatch
Copy link
Contributor

@ewatch ewatch commented May 31, 2021

If a component is not rendered because it doesn't exist the codegen still adds a closing parenthesis to the render function and therefore closes the last parent Element.

Changes

Adds additional marker for the code generator to know if a component was rendered and therefore isn't accidently closing the parent tag if not.

Testing

@changeset-bot
Copy link

changeset-bot bot commented May 31, 2021

⚠️ No Changeset found

Latest commit: 00afc6c

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

@ewatch ewatch changed the base branch from main to test/add-non-existant-import May 31, 2021 14:29
@ewatch ewatch changed the base branch from test/add-non-existant-import to main May 31, 2021 14:30
matthewp and others added 24 commits May 31, 2021 17:49
* Add benchmarking for the dev server

This adds benchmarking for the dev server.

* Use fs.rm instead

* Only rimraf if the folder exists

* Make uncached match CI

* Change the cached time too

* Don't run benchmark in CI

* Switch back test command

* Make tests be within 10 percent

* Use yarn to run multiple things

* Turn benchmark into uvu tests

* Debugging benchmark

* Print chunk for testing

* Ignore benchmark folder in uvu

* Add build benchmarking

* Update benchmark numbers
* documentation: post #231 merge renderers are a config option

* Update docs/config.md to reorder
* refactor: pluggable renderers

* refactor: cache renderer per component

* docs: update comments on snowpack plugin `transform` method

* docs: add comments to renderer plugins

* refactor: convert components to Map

* fix: pass children through to astro __render

* refactor: move Components/ComponentInfo to shared types

* refactor: remove `gatherRuntimes` step, just scan output for imports

* refactor: update isComponentTag logic

* chore: move dependencies to renderers

* fix: cross-platform transform injection

* feat: defer renderer to react, fallback to preact

* fix: use double quotes in generated script

* test: fix failing children tests

* test: add workspaceRoot to all tests

* fix: pass props to renderer check

* chore: add test:core script back for convenience

* chore: remove unused external

* chore: rename renderers

* chore: add astring, estree-util-value-to-estree

* chore: render-component => __astro_component

* refactor: split hydrate logic to own file

* refactor: use `astro-fragment` rather than `div`

* chore: remove unused hooks

* chore: delete unused file

* chore: add changesets

* fix: Astro renderer should be async

* fix: remove <astro-fragment> for static content

* test: fix failing test

* chore: normalize config interface

* feat: allow renderers to inject a snowpackPlugin

* fix: resolve import URL before using dynamic import

* refactor: update renderers to use separate /server entrypoint

* refactor: update server renderer interface

* fix: get renderers working again

* test: debug failing test

* test: better debug

* test: better debug

* test: remove debug

* fix: support esm and cjs packages via "resolve"

* refactor: split hydrate functions into individual files

* fix: dependency resolution relative to projectRoot

* fix: @snowpack/plugin-postcss needs to be hoisted

* fix: do not test prettier-plugin-astro as it's not ready for primetime
* chore: update getting started config #245

* chore: reorder renderers
* fix: remove remote urls from import scanner

* debug test
* fix: markdown issues

* wip: add docs example

* example: update doc template

* chore: credit Steph for AvatarList

* chore: align footer to bottom viewport

* chore: feeback R1

* fix: font fallback in firefox

* fix merge conflicts

* fix: add default value to headers

* chore: fix doc example
* feat: enable HMR in `createSnowpack`

* feat: enable Snowpack's HMR

* chore: add changeset

* chore: remove unused file

* chore: add changeset
* Fix codeblocks in markdown components

* Debugging

* More debugging

* remove extra debugging stuff
natemoo-re and others added 15 commits May 31, 2021 17:49
* chore: release vscode

* chore: move astro-languageserver deps to devDeps

* chore: enter pre
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* chore: add package.json to externals

* fix: add missing packages to allowList

* fix: temporarily disable @astrojs/renderer-vue

* chore: add changeset
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@@ -572,6 +573,7 @@ async function compileHtml(enterNode: TemplateNode, state: CodegenState, compile
paren++;
buffers[curr] += `h(${wrapper}, ${attributes ? generateAttributes(attributes) : 'null'}`;
} catch (err) {
state.markers.componentWasNotRendered = true;
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding a new marker, could you just use paren--? That should effectively do the same thing. paren is there to mark how many open parentheses need to be closed.

@matthewp
Copy link
Contributor

matthewp commented Jun 2, 2021

Rebasing with main should have the tests passing.

@matthewp
Copy link
Contributor

matthewp commented Jun 4, 2021

@ewatch no rush or anything, just a reminder that this should be good after a rebase.

@ewatch
Copy link
Contributor Author

ewatch commented Jun 6, 2021

Sure will take care of it. Thank you for the reminder @matthewp.
Thanks for the idea @natemoo-re. I will change it that way.

@FredKSchott
Copy link
Member

@ewatch friendly bump!

@ewatch ewatch requested a review from a team as a code owner June 13, 2021 22:18
@ewatch
Copy link
Contributor Author

ewatch commented Jun 15, 2021

Yeah I messed up my local branch. :-(
I will create a second branch with the small adaption, hope that's fine. And then we can close this.

@ewatch
Copy link
Contributor Author

ewatch commented Jun 17, 2021

see PR #490

@ewatch ewatch closed this Jun 17, 2021
@natemoo-re natemoo-re deleted the fix/closing-parent-tag-if-component-was-not-rendered branch June 17, 2021 22:19
ematipico pushed a commit that referenced this pull request Feb 6, 2025
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
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.

6 participants