Fix imports, use CDN/route for browser, avoid script-insertion hack, enable front-end frameworks to use library - #47
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
fsimport is implemented vianew Function(... import ...), which has the same CSP/unsafe-evalconcerns 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 resolvingfs, consider a build-time split (node vs browser entry) or bundler-specific ignore annotations rather than runtimeFunctionconstruction.
} 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.
Signed-off-by: Param Siddharth <contact@paramsid.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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