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

Cleanup dependencies #5773

Merged
merged 7 commits into from
Jan 10, 2023
Merged

Cleanup dependencies #5773

merged 7 commits into from
Jan 10, 2023

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jan 6, 2023

Changes

  • Removed unused dependencies
  • Refactor dependencies that're only used once, so it can be removed

I wanted to remove more, but the astro.js bin script, and astro add command uses a fair amount of packages that are only used once. And they can't be removed or it'll break the core feature.

Testing

Existing tests should pass.

Docs

Internal refactor. n/a

@changeset-bot
Copy link

changeset-bot bot commented Jan 6, 2023

🦋 Changeset detected

Latest commit: f74260e

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 the pkg: astro Related to the core `astro` package (scope) label Jan 6, 2023
plugins: Postcss.Plugin[];
}

async function resolvePostcssConfig(inlineOptions: any, root: URL): Promise<PostCSSConfigResult> {
Copy link
Member Author

Choose a reason for hiding this comment

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

This function is unused. The postcss and postcss-load-config deps can be removed along.

Comment on lines -48 to -60
function getSsrNoExternalDeps(projectRoot: URL): string[] {
let noExternalDeps = [];
for (const dep of ALWAYS_NOEXTERNAL) {
try {
resolveDependency(dep, projectRoot);
noExternalDeps.push(dep);
} catch {
// ignore dependency if *not* installed / present in your project
// prevents hard error from Vite!
}
}
return noExternalDeps;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Vite doesn't have an issue now if the deps are not installed. This enables removing resolveDependency and the resolve package.

Comment on lines -11 to +12
return npath.posix.join(getRootPath(base), href);
const rootPath = getRootPath(base);
const normalizedHref = slashify(href);
return appendForwardSlash(rootPath) + removeLeadingForwardSlash(normalizedHref);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the only place we use the path-browserify dep. I've emulated the posix join with this.

For reference, here's it's implementation: https://github.com/browserify/path-browserify/blob/872fec31a8bac7b9b43be0e54ef3037e0202c5fb/index.js#L180-L197

@@ -1,4 +1,4 @@
import { encode } from 'html-entities';
import { escape } from 'html-escaper';
Copy link
Member Author

Choose a reason for hiding this comment

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

html-entities and html-escaper do the same thing. Since we use html-escaper more, I've swap to it. html-entities was only used here once.

Comment on lines -21 to -23
const astroServerPath = fileURLToPath(
await importMetaResolve('astro/server/index.js', root.toString())
);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not needed anymore as I made a change to dedupe astro, which means we can refer to the string unresolved. We do the same for Astro compile too:

internalURL: 'astro/server/index.js',

@bluwy bluwy merged commit 4a1cabf into main Jan 10, 2023
@bluwy bluwy deleted the cleanup-deps branch January 10, 2023 07:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants