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

Simplify Vite Plugin #2183

Closed

Conversation

evoactivity
Copy link
Contributor

This will allow the vite config to just be

import { defineConfig } from 'vite';
import ember from '@embroider/vite';

export default defineConfig({
  plugins: [ember()],
});

assets(),
contentFor(),

babel({
Copy link
Collaborator

Choose a reason for hiding this comment

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

I liked your earlier suggestion of having babel present in the userland vite config.

folks may want to change this and it isn't "our" plugin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

babel would be configured with the babel config file, not in the vite config.

See react and vue vite plugins, they also setup babel but it's ultimately configured by the user with a babel config file.
https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/src/index.ts
https://github.com/vitejs/vite-plugin-vue/blob/599f81369816aca918314e86f5b0a6e32367bb38/packages/plugin-vue-jsx/src/index.ts#L4

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess if we're confident in our defaults, and want to align with everyone else, I'm game.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave this one open to see if anyone else has an opinion. I would vote for keeping this internal though, as users should only need to worry about babel.config.js, not how it actually is run on the files.

server: {
port: 4200,
},
build: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think build, and the choice to configure tests should be left to the user.

right now there some unease around /tests/ and the escape hatch we have in the existing vite config is to encourage changing /tests/ to /tests__whatever_i_want/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

for this one, specifically, I think it's better to expose always, for discoverability

Copy link
Contributor Author

@evoactivity evoactivity Nov 22, 2024

Choose a reason for hiding this comment

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

what if you could just do and we have this in the userland vite config?

ember({
  testUrl: 'tests/'
})

Copy link
Collaborator

Choose a reason for hiding this comment

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

why invent and maintain a new API tho?

Copy link
Collaborator

Choose a reason for hiding this comment

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

(i'll defer to others on this if they disagree with me, ofc)

Copy link
Contributor Author

@evoactivity evoactivity Nov 22, 2024

Choose a reason for hiding this comment

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

Actually maybe I need to understand this unease and escape hatch a litte more.

How would the user configure this, they would also need to rename the tests folder wouldn't they?

Copy link
Collaborator

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

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

excited for shrinking the "default" config, but i left some comments/questions/concerns

Copy link
Collaborator

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

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

ope

@evoactivity
Copy link
Contributor Author

Anyone have an idea why the CI bails out saying the lockfile needs to be updated? (I've ran pnpm and lockfile is not changing between runs)

@NullVoxPopuli
Copy link
Collaborator

does your tooling change your pnpm version based on the packageManager field? odds are you're using newer pnpm, and this repo is on pnpm 8

@evoactivity
Copy link
Contributor Author

I'm using volta with the pnpm flag enabled, so I think it should be, but it's installing 9 instead of 8, so I guess it's not.

@NullVoxPopuli
Copy link
Collaborator

yeah, we don't have a volta config in the package.jsons

@evoactivity
Copy link
Contributor Author

Ah ok, this would suggest otherwise
https://github.com/embroider-build/embroider/blob/main/CONTRIBUTING.md

@evoactivity
Copy link
Contributor Author

evoactivity commented Nov 23, 2024

Downgraded to pnpm 8.15.8 using corepack and now getting a strange typescript issue when running pnpm install, showing in CI as well.

prepare$ tsc -b && pnpm build-v2-addons
│ packages/macros/tests/babel/helpers.ts(85,15): error TS2454: Variable 'mode' is used before being assigned.

but it's not used before being assigned

for (let mode of ['build-time', 'run-time']) {
describe(mode, function () {
function applyMode(macrosConfig: MacrosConfig) {
if (mode === 'run-time') {

Changing it to a const for (const mode of ['build-time', 'run-time']) { makes it work 🫤

@evoactivity
Copy link
Contributor Author

Looks like typescript updated. Should that be pinned instead since stuff breaks often with typescript minor updates?

I don't understand why let mode is broken and const mode is fine, but 🤷

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.

2 participants