Skip to content

expose version variable from @sveltejs/kit #9937

@ivanhofer

Description

@ivanhofer

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 of SvelteKit 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.

import { version } from '@sveltejs/kit'
console.log(version)

Details

Probably the easiest solution would be to create a file /src/version.js

export const version = '1.16.3'

and expose it in /src/exports.js

export { version } from '../version.js' 
// ...

A script in CI (release.yml) would override the /src/version.js file with the actual version property from package.json.

Note: we can't just read and export the property from package.json because SvelteKit does not have a build-step and importing json files is curently not well supported in native Node.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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions