BUG: Compilation Error with Typescript
Question
GrapesJS version
- I confirm to use the latest version of GrapesJS
What browser are you using?
Crome 95
Reproducible demo link
none
Describe the bug
How to reproduce the bug?
- Add ts config file
{
"compileOnSave": false,
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"strict": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": false,
"strictNullChecks": false,
"baseUrl": "./",
"outDir": "./target/generated-typescript",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"moduleResolution": "Node",
"importHelpers": true,
"target": "es2017",
"module": "es2020",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
],
"paths": {
"uuid-random": [
"../node_modules/uuid-random"
],
"chroma-js": [
"../node_modules/chroma-js"
],
"faker/locale/en": [
"../node_modules/faker/locale/en"
],
"moment": [
"../node_modules/moment"
],
"validator": [
"../node_modules/validator"
],
"object-hash": [
"../node_modules/object-hash"
]
}
},
"angularCompilerOptions": {
"strictInjectionParameters": true,
"strictInputAccessModifiers": true
}
}
- Add grapes as dependency
- Import Grapes via
import * as grapesjs from 'grapesjs';and@import "~grapesjs/src/styles/scss/main.scss"; - Build your project
- Get the error
./node_modules/backbone/backbone.js - Error: Module not found: Error: Can't resolve 'jquery' in 'C:\Users\denny\IdeaProjects\WSPone-Platform\frontend\node_modules\backbone'
./node_modules/grapesjs/dist/grapes.min.js - Error: Module not found: Error: Can't resolve 'jquery' in 'C:\Users\denny\IdeaProjects\WSPone-Platform\frontend\node_modules\grapesjs\dist'
What is the expected behavior?
Should build like version .27
What is the current behavior?
So we've recently updated to grapes v17.28. With this particular version we get the error message when building our angular project. It is correct, that we don't have jquery as dependency. But for some reason backbone is requiring it now. The backbone version is still the same as with .27.
As soon as we revert our version to .27 it works totally fine.
The problematic code is
// Next for Node.js or CommonJS. jQuery may not be needed as a module.
} else if (typeof exports !== 'undefined') {
var _ = require('underscore'), $;
try { $ = require('jquery'); } catch (e) {}
factory(root, exports, _, $);
I saw that this project now has a tsconfig file, so it is compiling differently now? This might cause the issue
Code of Conduct
- I agree to follow this project's Code of Conduct
Answers (2)
Hi Denny, thanks for the report. I'm closing this in favor of #3902 as it should be related (even if the error is different). Please try the new version and let me know if it fixes the issue.
I'm working on a React + Typescript project and i'm having this same error on .28 version
Related Questions and Answers
Continue research with similar issue discussions.
Issue #5320
BUG: Upload Image or Asset is not triggering on File/Image selection
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? Chrome v114 Reproducible demo link none De...
Issue #5149
BUG: Non-named plugins and options
GrapesJS version [X] I confirm to use the latest version of GrapesJS What browser are you using? all and none, the bug is during the build...
Issue #4496
BUG: setStyle
GrapesJS version[X] I confirm to use the latest version of GrapesJSWhat browser are you using? chrome latest versionReproducible demo link...
Issue #6646
BUG: Javascript error when I want to add padding
GrapesJS version [x] I confirm to use the latest version of GrapesJS What browser are you using? Chrome & Firefox Reproducible demo link De...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.