Skip to content

Fix imports, use CDN/route for browser, avoid script-insertion hack, enable front-end frameworks to use library - #47

Merged
paramsiddharth merged 7 commits into
mainfrom
new-types-update-docs-4
May 25, 2026
Merged

Fix imports, use CDN/route for browser, avoid script-insertion hack, enable front-end frameworks to use library#47
paramsiddharth merged 7 commits into
mainfrom
new-types-update-docs-4

Conversation

@paramsiddharth

@paramsiddharth paramsiddharth commented May 25, 2026

Copy link
Copy Markdown
Owner

Fix imports, use CDN/route for browser, avoid script-insertion hack, enable front-end frameworks to use library

Resolves #39.

Signed-off-by: Param Siddharth contact@paramsid.com

Signed-off-by: Param Siddharth <contact@paramsid.com>
Signed-off-by: Param Siddharth <contact@paramsid.com>
Signed-off-by: Param Siddharth <contact@paramsid.com>
Signed-off-by: Param Siddharth <contact@paramsid.com>
… and browser (CDN)

Signed-off-by: Param Siddharth <contact@paramsid.com>
Signed-off-by: Param Siddharth <contact@paramsid.com>
Copilot AI review requested due to automatic review settings May 25, 2026 01:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Aksharamukha JS package to be consumable directly by front-end frameworks (and not only via a global-script pattern), while improving browser/Node initialization paths for loading Pyodide and wheels.

Changes:

  • Adjusts runtime initialization to support Node vs browser (local sub-route vs CDN) loading of Pyodide assets and wheels.
  • Updates package export conditions to make the ESM build the primary browser entrypoint.
  • Migrates the docs site from script-tag injection to importing the library directly as a dependency.

Reviewed changes

Copilot reviewed 11 out of 13 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tsup.config.ts Ensures pyodide.mjs is included in the dist artifact copy step.
src/constants.ts Introduces a CDN base URL used for browser fallbacks when loading Pyodide and wheels.
src/aksharamukha/index.ts Refactors initialization to dynamically load Pyodide and support multiple runtime paths (Node/local/CDN).
src/aksharamukha/index.test.ts Updates test setup to inject a Pyodide loader and fs for the new test-mode initialization logic.
package.json Updates conditional exports to use the ESM build for browser/import/node.
docs/src/components/ScriptShowcase.tsx Switches from window.aksharamukha usage to importing/initializing the client directly.
docs/src/components/LiveDemoSection.tsx Same as above; converts scripts to typed Scripts constants.
docs/src/components/ExamplesSection.tsx Removes the isLoaded prop and relies on internal initialization.
docs/src/app/page.tsx Removes script-insertion loader and uses components that self-initialize.
docs/package.json / docs/package-lock.json Adds the root package as a local file dependency for docs.
docs/next.config.ts Adjusts Next config for tracing root with static export.
.gitignore Adds .vscode/ and keeps /downloads/ ignored.
Files not reviewed (1)
  • docs/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

src/aksharamukha/index.ts:132

  • The Node-only fs import is implemented via new Function(... import ...), which has the same CSP/unsafe-eval concerns and may be blocked in hardened environments even if this branch is intended to be Node-only. If the goal is to stop browser bundlers from resolving fs, consider a build-time split (node vs browser entry) or bundler-specific ignore annotations rather than runtime Function construction.
			} else {
				// Keep import target non-literal so browser bundlers don't object to the import of "fs" in this Node-only block.
				fs = await (new Function('specifier', 'return import(specifier)') as (specifier: string) => Promise<typeof import('fs')>)('fs');
			}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/constants.ts
Comment thread src/aksharamukha/index.ts
Comment thread src/aksharamukha/index.ts
Comment thread src/aksharamukha/index.test.ts
Comment thread docs/src/components/ScriptShowcase.tsx
Comment thread docs/src/components/LiveDemoSection.tsx
Signed-off-by: Param Siddharth <contact@paramsid.com>
@paramsiddharth
paramsiddharth merged commit ea3784d into main May 25, 2026
2 checks passed
@paramsiddharth
paramsiddharth deleted the new-types-update-docs-4 branch May 25, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add compatibility for other React, Next.js, and compiled web frameworks

2 participants