Skip to content

How to extract version number from NPM module in 1.14.1 for CDN loading of WASM? #627

@richard-thomas

Description

@richard-thomas

Up to version 1.13.0 I was extracting the version using code:

// Extract sql.js version (to enable use of CDN for loading associated WASM)
import sqlJsPkg from 'sql.js/package.json' with { type: 'json' };
const sql_js_version = sqlJsPkg.version;

I was using this in code built with Vite/Webpack bundlers in order to load the correct WASM version from a CDN at runtime.

However, this no longer works in 1.14.1 due to the new restrictions in package.json of adding:

	"exports": {
		".": {
			"browser": "./dist/sql-wasm-browser.js",
			"default": "./dist/sql-wasm.js"
		},
		"./dist/*": "./dist/*"
	},

It was never a great way for me to extract the version as "import... with {type: 'json'}" depends on support for ES2025 features.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions