WIP: Migrate to unplugin #17

Closed
illright wants to merge 2 commits from main into main
illright commented 2023-11-08 11:01:54 +01:00 (Migrated from github.com)

I drafted a solution to migrate to unplugin, but ran into some issues in the process. Since we introduce an additional build-time dependency, we need to bundle it to avoid burdening the end user. That means we no longer can simply externalize every dependency and let Node figure it out.

For that reason, I slightly edited the building logic. I decided to replace Rollup with esbuild because it's more out-of-the-box, requires no plugins and less fiddling. That brought me to the problem of the @lezer/lr package which contains a ./dist/constants.js file that actually exports nothing, and isn't mentioned in the exports field of package.json. To proceed with this, we need to remedy those issues in @lezer/lr.

Closes https://github.com/lezer-parser/lezer/issues/48

I drafted a solution to migrate to unplugin, but ran into some issues in the process. Since we introduce an additional build-time dependency, we need to bundle it to avoid burdening the end user. That means we no longer can simply externalize every dependency and let Node figure it out. For that reason, I slightly edited the building logic. I decided to replace Rollup with esbuild because it's more out-of-the-box, requires no plugins and less fiddling. That brought me to the problem of the `@lezer/lr` package which contains a `./dist/constants.js` file that actually exports nothing, and isn't mentioned in the `exports` field of `package.json`. To proceed with this, we need to remedy those issues in `@lezer/lr`. Closes https://github.com/lezer-parser/lezer/issues/48
illright commented 2023-11-08 14:57:42 +01:00 (Migrated from github.com)

This PR should address the issues I'm facing with the lr package: https://github.com/lezer-parser/lr/pull/64

This PR should address the issues I'm facing with the `lr` package: https://github.com/lezer-parser/lr/pull/64
marijnh commented 2023-11-08 15:00:44 +01:00 (Migrated from github.com)

Since we introduce an additional build-time dependency, we need to bundle it to avoid burdening the end user

Why would you need to bundle a build-time dependency?

I decided to replace Rollup with esbuild

That's not something I'm willing to go along with.

> Since we introduce an additional build-time dependency, we need to bundle it to avoid burdening the end user Why would you need to bundle a build-time dependency? > I decided to replace Rollup with esbuild That's not something I'm willing to go along with.
illright commented 2023-11-08 15:36:52 +01:00 (Migrated from github.com)

Why would you need to bundle a build-time dependency?

Because we don't want to make end users have to install unplugin to use the plugin

That's not something I'm willing to go along with.

Why? And how would you suggest to tackle the bundling of the plugin?

> Why would you need to bundle a build-time dependency? Because we don't want to make end users have to install unplugin to use the plugin > That's not something I'm willing to go along with. Why? And how would you suggest to tackle the bundling of the plugin?
marijnh commented 2023-11-08 16:02:14 +01:00 (Migrated from github.com)
 Because we don't want to make end users have to install unplugin to use the plugin

Isn't that how the npm ecosystem works? You install dependencies when you need them.

> Because we don't want to make end users have to install unplugin to use the plugin Isn't that how the npm ecosystem works? You install dependencies when you need them.
illright commented 2023-11-08 16:51:47 +01:00 (Migrated from github.com)

Isn't that how the npm ecosystem works? You install dependencies when you need them.

Not precisely. You install dependencies when you need them, but it is expected that these dependencies will take of bundling themselves and not require you to do it in your project.

Here's a very popular unplugin, unplugin-icons, installing it doesn't require you to install its build dependency unplugin.

> Isn't that how the npm ecosystem works? You install dependencies when you need them. Not precisely. You install dependencies when you need them, but it is expected that these dependencies will take of bundling themselves and not require you to do it in your project. Here's a very popular unplugin, [`unplugin-icons`](https://github.com/unplugin/unplugin-icons), installing it doesn't require you to install its build dependency `unplugin`.
marijnh commented 2023-11-08 17:16:43 +01:00 (Migrated from github.com)

Why would users be required to bundle the unplugin dependency? Can't it just be loaded from node_modules like usual?

Why would users be required to bundle the unplugin dependency? Can't it just be loaded from node_modules like usual?
illright commented 2023-11-08 17:19:42 +01:00 (Migrated from github.com)

Not if it's explicitly declared as a dependency, especially for stricter package managers like pnpm.

Not if it's explicitly declared as a dependency, especially for stricter package managers like pnpm.
marijnh commented 2023-11-08 17:21:27 +01:00 (Migrated from github.com)

Obviously it'd have to be declared as a dependency, yes.

Obviously it'd have to be declared as a dependency, yes.
illright commented 2023-11-08 17:23:35 +01:00 (Migrated from github.com)

I sense a lot of resistance both here and in my other PR that you closed. I have no interest in trying to convince you that my approach to libraries is any better, I just want to use Lezer from ESBuild. If you're not willing to accept this PR, I will just create the unplugin in a separate repo and publish it as a separate package.

I sense a lot of resistance both here and in my other PR that you closed. I have no interest in trying to convince you that my approach to libraries is any better, I just want to use Lezer from ESBuild. If you're not willing to accept this PR, I will just create the unplugin in a separate repo and publish it as a separate package.
marijnh commented 2023-11-08 17:28:35 +01:00 (Migrated from github.com)

That's probably for the best.

Coming into a project and reorganizing stuff wholesale to fit your preferred approach is not always going to be welcome.

That's probably for the best. Coming into a project and reorganizing stuff wholesale to fit your preferred approach is not always going to be welcome.
illright commented 2023-11-08 17:59:02 +01:00 (Migrated from github.com)

Here it is, in case you want to add a note about it: https://www.npmjs.com/package/unplugin-lezer. It's a shame we couldn't come to a consensus.

Here it is, in case you want to add a note about it: https://www.npmjs.com/package/unplugin-lezer. It's a shame we couldn't come to a consensus.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lezer/generator!17
No description provided.