-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
export map breaks rollup plugin, others trying to import/require ('svelte/package.json') #5659
Comments
Since this went out as a patch release, I'd recommend a quick follow up patch to add. |
|
@MylesBorins is there a thread where this "package.json not automatically included in export map" behavior is already being discussed? I've seen this issue bite so many packages trying to upgrade to an export map, and it's only going to keep happening. If it hasn't been proposed yet, I'd like to start a thread. |
Thanks! Fixed in 3.29.6 - https://unpkg.com/svelte@3.29.6/package.json |
not fixed, now I get error for
|
The export map contains
Which I assume means that things need to use |
yes, rollup |
Yeah, I see it at https://github.com/sveltejs/rollup-plugin-svelte/blob/65fbfc7824b7e86e546ed064bf6d94b87ebb7b37/index.js#L15 - This will be fixed in the next major version of the Rollup plugin, but we should either also support importing from |
This should be fixed with rollup-plugin-svelte@6.1.1. |
yup, it's fixed. Thx! |
Oh hi! There is a historical thread nodejs/modules#445 TL;DR while it is "unexpected" today, the general intent of exports is to make the contract for a module explicit, and the general thought was that exposing the package.json as part of the module API should be opt-in by the module author Making a carve out in exports for One solution that has been discussion is exposing an API in Node.js core that would make it easy for tools / module consumers to easily get the path to a package.json. This is being discussed in nodejs/node#49445 With this type of util api you would be able to do something like import { readFile } from 'fs/promises';
import { resolvePackageRoot } from 'module';
const svelteRoot = await resolvePackageRoot('svelte');
const svelteJSON = JSON.parse(await readFile(svelteRoot + '/package.json')); While this is definitely more verbose it would be consistent and reliable for all packages while still allowing a module author to not make the package.json part of their packages API by default. |
Thanks @MylesBorins, responded in historical thread. |
Build silently failing due to sveltejs/svelte#5659
Update package.json exports to include package.json. Why package.json needs to export itself, I cannot say but it fixes the following Svelte rollup.js plugin warning: [rollup-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file. - browser-fs-access I've verified locally using `npm link` that the warning no longer occurs with this change in my Svelte project. I _believe_ the otherwise preexisting exports behavior is preserved. References: - [Official documentation](https://nodejs.org/api/packages.html#packages_exports) and [much more useful documentation with examples from the proposal](https://github.com/jkrems/proposal-pkg-exports) - [Similar issue for a different package](sveltejs/svelte#5659) and [its resolution](https://unpkg.com/svelte@3.29.6/package.json)
Update package.json exports to include package.json. Why package.json needs to export itself, I cannot say but it fixes the following Svelte rollup.js plugin warning: [rollup-plugin-svelte] The following packages did not export their `package.json` file so we could not check the "svelte" field. If you had difficulties importing svelte components from a package, then please contact the author and ask them to export the package.json file. - browser-fs-access I've verified locally using `npm link` that the warning no longer occurs with this change in my Svelte project. I _believe_ the otherwise preexisting exports behavior is preserved. References: - [Official documentation](https://nodejs.org/api/packages.html#packages_exports) and [much more useful documentation with examples from the proposal](https://github.com/jkrems/proposal-pkg-exports) - [Similar issue for a different package](sveltejs/svelte#5659) and [its resolution](https://unpkg.com/svelte@3.29.6/package.json)
Congrats on releasing the new export map! Quick issue spotted: Node.js doesn't default to include the package.json file as part of your package, meaning tooling/consumers can't `require('svelte/package.json'). The Rollup plugin currently does this, as do many others.
Snowpack's Svelte template is broken as a result.
The fix is to add this to your export map:
"exports": { + "./package.json": "./package.json" }
The text was updated successfully, but these errors were encountered: