sql-js / sql-js/sql.js

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

Open
#627 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
13.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading package.json, especially the exports map, and compare it with the issue's version import used by Vite and Webpack builds. Check how the package is published in 1.14.1 and how the CDN URL is assembled. Done means identifying a supported way to obtain the package version without relying on the unsupported import path or newer syntax.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, vite, wasm, webpack
Domain
build-system, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.