When bundling Parse JS SDK client through VITE - vue's new bundler, based on snowpack - compilation fails due to an error caused in parse.
npm iNOTE: parse lib is imported in src/App.vue
Uncaught TypeError: Super expression must either be null or a function
_inherits Babel
Subscription LiveQuerySubscription.js:149
js LiveQuerySubscription.js:197
__require chunk-BIJEITIM.js:6
js LiveQueryClient.js:65
__require chunk-BIJEITIM.js:6
js ParseLiveQuery.js:25
__require chunk-BIJEITIM.js:6
js Parse.js:286
__require chunk-BIJEITIM.js:6
js index.js:1
__require chunk-BIJEITIM.js:6
<anonymous> parse:1
This is the code at 149:
var Subscription = /*#__PURE__*/function (_EventEmitter) { << 149
(0, _inherits2.default)(Subscription, _EventEmitter);
var _super = _createSuper(Subscription);
// ....
I expected Parse to be bundled without error
"parse": "^3.2.0",
Server
Database
Client
No logs - see error in console
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 parse to my tsconfig.json types array.
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?
// ES6 Minimized
import Parse from 'parse/dist/parse.min.js';
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 parse package types.
Edit: I got TypeScript to play nice with the minified import by adding this to my tsconfig.json compilerOptions:
"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"]
}
}
}
Most helpful comment
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
parsepackage types.Edit: I got TypeScript to play nice with the minified import by adding this to my
tsconfig.jsoncompilerOptions: