-
-
Notifications
You must be signed in to change notification settings - Fork 594
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
TypeError when bundling latest Parse JS SDK using VITE (the vue bundler) #1362
Comments
Can you try using the CDN? https://cdnjs.cloudflare.com/ajax/libs/parse/3.2.0/parse.min.js |
The CDN build doesn't emit the error. But having the NPM build work would be preferable, since it plays nicer with Typescript, build pipelines, etc. I got the types to work with the CDN script by adding |
We got the same problem while using this in React as well, same things with Snowpack as well. |
Can you try to import from the dist/minified build? |
Yes, confirm that does get bundled properly and without errors. |
Yep, that functions correctly, though I think I'll have to stick with the CDN approach for the moment - TypeScript doesn't know how to match that import up with the Edit: I got TypeScript to play nice with the minified import by adding this to my "baseUrl": ".",
"paths": {"parse/dist/parse.min.js": ["node_modules/@types/parse/index.d.ts"]} |
I hit the same issue with SvelteKit which is based on Vite. The minified version solved the issue for me as well. |
@GormanFletcher Thank you very much for the solution. Formatted version {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"parse/dist/parse.min": ["node_modules/@types/parse/index.d.ts"]
}
}
} |
I experienced the same issue today while migrating my Vue project to Vite. I created this minimal Codesandbox repro before finding this issue.. hope it helps. I also created a post on ParsePlatform Community with more details on what happens when the error is thrown. |
@dblythy you are a vue expert, what's your opinion on this? Looks like a nuisance that should be fixed, do you have any idea about the scope of this? |
I solved this in my projects using The error was:
This seems to possibly be an issue with I ended up using |
The workaround is to use the minimized parse distribution Issues described more fully here: parse-community/Parse-SDK-JS#1362
Still an issue with the current version of the JS SDK. FYI, if you are not using typescript with Vite, I got my VSCode intellisense autocomplete working by adding {
"compilerOptions": {
"baseUrl": ".",
"paths": {
"parse/dist/parse.min.js": [
"./node_modules/@types/parse/index.d.ts"
]
}
}
} |
@tremendus can you try adding this to your Vite configuration:
|
I guess this is already solved since the last release (4.3.1). |
So can this issue be closed? |
Is it still not fixed 3 years later? |
This appears to have been fixed. I'm on Vite @ 5.0.8, parse @ 4.3.1. Method 1: // results in browser console warning, but no errors:
// parse.js?v=8db0138c:26206 Module "events" has been externalized for browser compatibility. Cannot access "events.EventEmitter" in client code. See https://vitejs.dev/guide/troubleshooting.html#module-externalized-for-b
import Parse from 'parse'; Method 2: // no warnings or errors (for intellisense support this needs modified tsconfig.json)
import Parse from 'parse/dist/parse.min.js' |
Did the same in my SvelteKit project, solved types error 🤜🏼🤛🏼 |
New Issue Checklist
Issue Description
When bundling Parse JS SDK client through VITE - vue's new bundler, based on snowpack - compilation fails due to an error caused in parse.
Steps to reproduce
npm i
NOTE: parse lib is imported in src/App.vue
Actual Outcome
This is the code at 149:
Expected Outcome
I expected Parse to be bundled without error
Environment
"parse": "^3.2.0",
Server
Database
Client
Logs
No logs - see error in console
The text was updated successfully, but these errors were encountered: