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

Remove shamefully-hoist #4842

Merged
merged 28 commits into from
Sep 28, 2022
Merged

Remove shamefully-hoist #4842

merged 28 commits into from
Sep 28, 2022

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Sep 22, 2022

Changes

  • Remove the need for shamefully-hoist=true in the Astro codebase and user project.
  • Add a bunch of missing deps due to reliance of hoisting before.
  • Bug fixes for @astrojs/rss and @astrojs/markdown-remark.

Testing

All tests should pass

Docs

N/A. It doesn't look like the docs touch on shamefully-hoist, so I think this change could be made transparently.

@changeset-bot
Copy link

changeset-bot bot commented Sep 22, 2022

🦋 Changeset detected

Latest commit: d7afd58

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) pkg: lit Related to Lit (scope) pkg: preact Related to Preact (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope) pkg: integration Related to any renderer integration (scope) feat: markdown Related to Markdown (scope) labels Sep 22, 2022
@github-actions github-actions bot added the 🚨 action Modifies GitHub Actions label Sep 26, 2022
@bluwy bluwy marked this pull request as ready for review September 26, 2022 15:59
/** Normalize URL to its canonical form */
export function createCanonicalURL(url: string, base?: string): URL {
let pathname = url.replace(/\/index.html$/, ''); // index.html is not canonical
pathname = pathname.replace(/\/1\/?$/, ''); // neither is a trailing /1/ (impl. detail of collections)
if (!npath.extname(pathname)) pathname = pathname.replace(/(\/+)?$/, '/'); // add trailing slash if there’s no extension
if (!getUrlExtension(url)) pathname = pathname.replace(/(\/+)?$/, '/'); // add trailing slash if there’s no extension
Copy link
Member Author

@bluwy bluwy Sep 26, 2022

Choose a reason for hiding this comment

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

Question: could we use path.extname from node here? I'm not sure since it imported path-browserify before (maybe just a auto-import issue).

Context: path-browserify was imported by astro-rss before but was not declared as dependency. Thought we could simplify remove the package with a simpler replacement.

// NOTE: Sometimes, tests fail with `TypeError: process.stdout.clearLine is not a function`
// for some reason. This comes from Vite, and is conditionally called based on `isTTY`.
// We set it to false here to skip this odd behavior.
process.stdout.isTTY = false;
Copy link
Member Author

Choose a reason for hiding this comment

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

I hit this special case locally where e2e is failing on process.stdout.clearLine for some reason. It's not related to the shamefully-hoist change from what I can tell.

Comment on lines +269 to +271
ssr: {
external: ['@astrojs/mdx', '@astrojs/react'],
},
Copy link
Member Author

@bluwy bluwy Sep 26, 2022

Choose a reason for hiding this comment

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

Added these packages to tryLoadConfig. There's no way to externalize everything always in Vite, so this was the best I could find fixing this.

NOTE: there's a comment explaining this above the highlight change

@matthewp
Copy link
Contributor

@bluwy have you tried this outside of the monorepo? If not we can create a preview release for this in order to test it out.

@bluwy bluwy linked an issue Sep 27, 2022 that may be closed by this pull request
1 task
@bluwy
Copy link
Member Author

bluwy commented Sep 27, 2022

Yeah I've tested this with https://github.com/bluwy/whyframe/tree/master/docs and the basics template + Svelte/Lit framework locally, which seems to work. The complex part of the PR is getting strict hoist to work in Astro itself, but getting strict hoist to work in user projects is simpler.

The main takeaway that maybe we should document is that:

  1. For Lit projects, they need to add public-hoist-pattern[]=*lit* to .npmrc.
  2. If they use legacy markdown, they need to install github-slugger.

The rest should be working as is.

@matthewp matthewp added the semver: minor Change triggers a `minor` release label Sep 27, 2022
Copy link
Contributor

@matthewp matthewp left a comment

Choose a reason for hiding this comment

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

Since this is a biggish change, let's make this go in the next minor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚨 action Modifies GitHub Actions feat: markdown Related to Markdown (scope) pkg: astro Related to the core `astro` package (scope) pkg: integration Related to any renderer integration (scope) pkg: lit Related to Lit (scope) pkg: preact Related to Preact (scope) pkg: svelte Related to Svelte (scope) pkg: vue Related to Vue (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.yarnrc.yml for Yarn, via create-astro?
2 participants