-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[svelte-kit] Cannot Load ES module from agnostic-helpers #238
Comments
Thanks for the bug and fix 🙏🏽 |
I got the same error, thank you for the suggestion. @eli-xciv May I ask when will this fix be updated to NPM package? @roblevintennis |
Bumping this, as 1.1.27 is still the version NPM installs and this still happens on sveltekit projects. |
Hey y'all I reopened this. Life is getting in my way at the moment so I cannot bump the version but once I can get back to AgnosticUI work this will be a priority. Apologies for the inconvenience. |
@don-wang and @hahuang65 If you need it included with an npm build you can manually copy the package from Here's what I did to get the build working for a netlify deployment
You're project will use the local custom agnostic helpers rather than the published version |
A programmatic patcher: //Imports (CommonJS only)
// const {dirname, join} = require('path');
// const {readFileSync, writeFileSync} = require('fs');
//Imports (ES Module only)
import {dirname, join} from 'path';
import {fileURLToPath} from 'url';
import {readFileSync, writeFileSync} from 'fs';
//Get the directory of this file (ES Module only)
const __dirname = dirname(fileURLToPath(import.meta.url));
//You may need to change this depending on the location of this file
const target = join(__dirname, 'node_modules/agnostic-helpers/package.json');
//Patch the package.json file
const pkg = JSON.parse(readFileSync(target, 'utf-8'));
pkg.type = 'module';
writeFileSync(target, JSON.stringify(pkg, null, 2));
console.log(`Patched ${target}`); Then just add the below to your project's {
"scripts": {
+ "postinstall": "node [PATH TO THE ABOVE FILE]",
}
} And the patch will always be applied after any |
Sorry for the delay. I'm starting to slowly get back into things over here. I went ahead and published agnostic-helpers 1.03 version with @eli-xciv fix and pointed the packages to it e.g. for agnostic-svelte: That said, you'd have to temporarily point to
I haven't tested but maybe it's something like this?
Let me know if this is at all helpful or not. I'm hoping to get agnostic-svelte-ts to parity so I can just replace agnostic-svelte with that (and get the proper typings for free etc. etc. I think I just need to finish the Pagination component to do that so it's fairly close I think) |
Describe the bug
sveltekit/vite cannot load ESM module:
agnostic-helpers
To Reproduce
Steps to reproduce the behavior:
agnostic-svelte
npm run dev
Expected behavior
Local development server loads.
I was able to work around this error by adding
"type":"module"
to{PATH}/node_modules/agnostic-helpers/package.json
Desktop (please complete the following information):
"agnostic-svelte": "^1.1.27"
The text was updated successfully, but these errors were encountered: