exposed package.json in export map #349

Closed
twop wants to merge 1 commit from patch-1 into master
twop commented 2020-12-14 00:29:10 +01:00 (Migrated from github.com)

Motivation and context here:
https://github.com/snowpackjs/snowpack/discussions/1954#discussioncomment-203114

there is even a discussion to make package.json to be a special case but it was closed :( https://github.com/nodejs/modules/issues/445

In short, modern tooling need to be able to resolve package.json, hence it needs to be added to the export map.

Motivation and context here: https://github.com/snowpackjs/snowpack/discussions/1954#discussioncomment-203114 there is even a discussion to make `package.json` to be a special case but it was closed :( https://github.com/nodejs/modules/issues/445 In short, modern tooling need to be able to resolve `package.json`, hence it needs to be added to the export map.
marijnh commented 2020-12-14 08:43:19 +01:00 (Migrated from github.com)

The plan is for the packages (once split out of the monorepo) to have a regular main export. That would resolve this, right? In the meantime, I'm okay with merging a PR that explicitly adds package.json to the exports.

The plan is for the packages (once split out of the monorepo) to have a regular main export. That would resolve this, right? In the meantime, I'm okay with merging a PR that explicitly adds package.json to the exports.
twop commented 2020-12-14 18:58:51 +01:00 (Migrated from github.com)

My understanding is that it is almost a requirement to list package.json If you use exported map. I’m not sure what is your vision for distribution. As a reference point preact lists a bunch of entry points for different formats via export map.
From preact/package.json

"exports": {
		".": {
			"browser": "./dist/preact.module.js",
			"umd": "./dist/preact.umd.js",
			"import": "./dist/preact.mjs",
			"require": "./dist/preact.js"
		},
               // a bunch of others
               “./pacakage.json”:  “./pacakage.json”
}

https://github.com/preactjs/preact/blob/master/package.json

I assume with a single entry point you can just omit exported field.

My understanding is that it is almost a requirement to list `package.json` If you use `exported` map. I’m not sure what is your vision for distribution. As a reference point preact lists a bunch of entry points for different formats via export map. From preact/package.json ```json "exports": { ".": { "browser": "./dist/preact.module.js", "umd": "./dist/preact.umd.js", "import": "./dist/preact.mjs", "require": "./dist/preact.js" }, // a bunch of others “./pacakage.json”: “./pacakage.json” } ``` https://github.com/preactjs/preact/blob/master/package.json I assume with a single entry point you can just omit `exported` field.
marijnh commented 2020-12-14 21:08:40 +01:00 (Migrated from github.com)

The issue you linked mentions a workaround where they resolve "." and then walk up the directory structure from there, which would be the reason why this doesn't cause problems with every single exports-using package.

The issue you linked mentions a workaround where they resolve `"."` and then walk up the directory structure from there, which would be the reason why this doesn't cause problems with every single `exports`-using package.
marijnh commented 2020-12-14 21:09:27 +01:00 (Migrated from github.com)

There is nothing at ./ in the current package though, so I don't think adding that export helps at all. Does it solve a particular problem?

There is nothing at `./` in the current package though, so I don't think adding that export helps at all. Does it solve a particular problem?
twop commented 2020-12-14 21:20:50 +01:00 (Migrated from github.com)

My understanding is that it can be needed for some tools. E.g. traverse the folder structure starting from ./

I think only exposing package.json will solve snowpack issue, because it looks explicitly just for it.

My understanding is that it can be needed for some tools. E.g. traverse the folder structure starting from `./` I think only exposing package.json will solve snowpack issue, because it looks explicitly just for it.
marijnh commented 2020-12-15 08:21:15 +01:00 (Migrated from github.com)

I've merged the package.json part as b2ca4c8

I've merged the package.json part as b2ca4c8

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
codemirror/dev!349
No description provided.