-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
expose version
variable from @sveltejs/kit
#9937
Comments
The import pkg from '@sveltejs/kit/package.json' assert { type: 'json' };
console.log(pkg.version); |
I was also thinking about that first. But Import assertions are still experimental: https://nodejs.org/api/esm.html#import-assertions
Import assertions were backported to Node |
Given that we can achieve this with an experimental feature, I'd prefer not to add the feature to Kit -- if, in the future, the experimental feature is dropped or we can't use it for some reason, then we could circle back to this. The warning is annoying -- is there any way we could suppress it? |
Import assertions don't currently work inside
I forget why we did that, but I'm not sure it's a good practice. (IIRC some Svelte bundler plugins used it at one point to determine if a given package was a Svelte library or not, but that caused problems and is no longer the case.) I don't think it's a widespread habit, and to be honest I'd be in favour of removing it from the exports map in v2. So for those two reasons, combined with the two |
That's fair. It would be nice if we could get this to work somehow other than adding more moving parts to automatically update this file, but I'm not sure that would be possible, given the unbundled nature of the package. |
I have created a PR: #9969 |
Closes #9937 --------- Co-authored-by: Rich Harris <hello@rich-harris.dev> Co-authored-by: Ben McCann <322311+benmccann@users.noreply.github.com> Co-authored-by: Rich Harris <git@rich-harris.dev> Co-authored-by: Ivan Hofer <ivan.hofer@outlok.com>
Describe the problem
inlang creates an i18n solution that integrates well into any SvelteKit application. We set things up in an automated way, so we need to know which features are available in the current installed version of
SvelteKit
.e.g. the
entries
feature was recently introduced and we want to use it, but we can't really tell if it is supported becasue we don't know the installed version ofSvelteKit
on a developer's machine. If we would just add it,SvelteKit
would throw an error.We currently use
npm list --depth=0 @sveltejs/kit
to read the information, but it is not really reliable.Therefore it would be great if
SvelteKit
would expose the version info.Describe the proposed solution
expose a
version
prop that can be read by any application.Details
Probably the easiest solution would be to create a file
/src/version.js
and expose it in
/src/exports.js
A script in CI (
release.yml
) would override the/src/version.js
file with the actualversion
property frompackage.json
.Note: we can't just read and export the property from
package.json
becauseSvelteKit
does not have a build-step and importingjson
files is curently not well supported in nativeNode.js
.Alternatives considered
None
Importance
would make my life easier
Additional Information
If this is something the
SvelteKit
team considers, I can create a PR in the coming days.The text was updated successfully, but these errors were encountered: