GrapesJS / grapesjs

Free and Open source Web Builder Framework. Next generation tool for building templates without coding
https://grapesjs.com
BSD 3-Clause "New" or "Revised" License
22.36k stars 4.05k forks source link

BUG: export 'default' not found in 'backbone' (module has no exports) #4854

Closed mnutt closed 1 year ago

mnutt commented 1 year ago

GrapesJS version

What browser are you using?

Firefox 109

Reproducible demo link

none

Describe the bug

How to reproduce the bug?

(clone repo)
$ yarn
$ yarn start

What is the expected behavior?

The development server starts.

What is the current behavior?

yarn run v1.22.18
$ run-p start:*
$ npm run build:css -- --watch
$ grapesjs-cli serve

> grapesjs@0.20.4 build:css
> sass src/styles/scss/main.scss dist/css/grapes.min.css --no-source-map --style=compressed --load-path=node_modules --watch

Start the development server...

Sass is watching for changes. Press Ctrl-C to stop.

<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: http://localhost:8080/
<i> [webpack-dev-server] On Your Network (IPv4): http://10.10.0.235:8080/
<i> [webpack-dev-server] On Your Network (IPv6): http://[fe80::1]:8080/
<i> [webpack-dev-server] Content not from webpack is served from '/Users/mnutt/p/src/grapesjs' directory
<i> [webpack-dev-middleware] wait until bundle finished: /
asset grapes.min.js 3.15 MiB [emitted] (name: main)
asset index.html 3.92 KiB [emitted]
runtime modules 27.7 KiB 14 modules
orphan modules 465 bytes [orphan] 5 modules
modules by path ./src/ 1.5 MiB 245 modules
modules by path ./node_modules/ 926 KiB
  modules by path ./node_modules/underscore/modules/*.js 83.5 KiB 161 modules
  modules by path ./node_modules/@babel/runtime/ 9.01 KiB 25 modules
  modules by path ./node_modules/grapesjs-cli/node_modules/ 177 KiB 20 modules
  modules by path ./node_modules/codemirror/ 517 KiB
    ./node_modules/codemirror/lib/codemirror.js 417 KiB [built] [code generated]
    + 4 modules
  modules by path ./node_modules/promise-polyfill/src/*.js 7.48 KiB
    ./node_modules/promise-polyfill/src/index.js 5.84 KiB [built] [code generated]
    + 2 modules
  + 5 modules

WARNING in ./node_modules/grapesjs-cli/node_modules/webpack-dev-server/client/overlay.js 29:0-18
export 'default' (imported as 'ansiHTML') was not found in 'ansi-html-community' (module has no exports)
 @ ./node_modules/grapesjs-cli/node_modules/webpack-dev-server/client/index.js?protocol=ws%3A&hostname=0.0.0.0&port=8080&pathname=%2Fws&logging=info&reconnect=10 9:0-57 107:6-10 165:6-10 174:6-10 205:27-40 222:6-10 239:28-41 256:6-10 270:6-10

WARNING in ./node_modules/grapesjs-cli/node_modules/webpack-dev-server/client/overlay.js 199:17-25
export 'default' (imported as 'ansiHTML') was not found in 'ansi-html-community' (module has no exports)
 @ ./node_modules/grapesjs-cli/node_modules/webpack-dev-server/client/index.js?protocol=ws%3A&hostname=0.0.0.0&port=8080&pathname=%2Fws&logging=info&reconnect=10 9:0-57 107:6-10 165:6-10 174:6-10 205:27-40 222:6-10 239:28-41 256:6-10 270:6-10

<snip, lots of other errors like this>

ERROR in ./node_modules/@babel/runtime/regenerator/index.js 1:0
Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
File was processed with these loaders:
 * ./node_modules/grapesjs-cli/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
> import _typeof from "@babel/runtime/helpers/typeof";
| 
| // TODO(Babel 8): Remove this file.
 @ ./src/dom_components/view/ComponentTextView.js 13:0-61 104:54-78 109:15-39 185:60-84 193:15-39
 @ ./src/dom_components/index.ts 131:0-57 235:22-39
 @ ./src/editor/model/Editor.ts 110:4-29
 @ ./src/editor/index.ts 59:0-41 80:22-33
 @ ./src/index.js 9:0-30 57:21-27

webpack 5.73.0 compiled with 1 error and 44 warnings in 7381 ms

I'm using node v16.18.1 (MacOS) although had the same result on node 14 and node 18. Is there something obvious I'm doing wrong?

Code of Conduct

mnutt commented 1 year ago

I was able to circumvent this error by changing the build pipeline to output more modern javascript (via --targets="> 3%"), though that produces backbone errors due to the use of es6 classes.

artf commented 1 year ago

I'm not able to reproduce on my side with a fresh install, are you using the dev branch?

mnutt commented 1 year ago

Yes, this is from dev HEAD (094c1ca0be13af4ba6e9b7f48e98661d60eddaf4) as of this morning:

https://gist.github.com/mnutt/283db8bef18b7e105edd9ffbe84205ea

mnutt commented 1 year ago

I was able to reproduce the same result on linux with this Dockerfile:

FROM node:16

WORKDIR /usr/src/app
COPY package.json yarn.lock ./
RUN yarn install
COPY . .
EXPOSE 8080
CMD [ "yarn", "start" ]
docker build -t grapesjs-dev .
docker run --rm -it -p 8080:8080 grapesjs-dev
artf commented 1 year ago

The one difference I notice on my side is the import of babel modules

modules by path ./node_modules/ 850 KiB
  modules by path ./node_modules/underscore/modules/*.js 83.1 KiB 161 modules
  modules by path ./node_modules/grapesjs-cli/node_modules/ 142 KiB 20 modules
  modules by path ./node_modules/codemirror/ 488 KiB 5 modules
  modules by path ./node_modules/@babel/runtime/helpers/esm/*.js 1.35 KiB
    ./node_modules/@babel/runtime/helpers/esm/defineProperty.js 344 bytes [built] [code generated]
    + 3 modules
  modules by path ./node_modules/promise-polyfill/src/*.js 8.39 KiB
    ./node_modules/promise-polyfill/src/index.js 5.83 KiB [built] [code generated]
    + 3 modules
  + 5 modules

Not sure why your is using the whole ./node_modules/@babel/runtime/ path. I wonder if you're able to reproduce the issue with other grapesjs related plugins that rely on the grapesjs-cli (eg. grapesjs-style-filter)

mnutt commented 1 year ago

Yes, I'm able to reproduce it on grapesjs-style-filter too, same types of errors.

artf commented 1 year ago

@mnutt can you try with the latest grapesjs-cli version please

mnutt commented 1 year ago

Sadly, the same errors with grapesjs-cli 4.0.0 😢 . And as you noticed before, it uses the whole module path:

orphan modules 501 bytes [orphan] 5 modules
modules by path ./src/ 1.49 MiB 245 modules
modules by path ./node_modules/ 918 KiB
  modules by path ./node_modules/underscore/modules/*.js 83.2 KiB 161 modules
  modules by path ./node_modules/grapesjs-cli/node_modules/ 180 KiB 21 modules
  modules by path ./node_modules/codemirror/ 515 KiB 5 modules
  modules by path ./node_modules/promise-polyfill/src/*.js 7.42 KiB
    ./node_modules/promise-polyfill/src/index.js 5.79 KiB [built] [code generated]
    + 2 modules
  modules by path ./node_modules/@babel/runtime/helpers/esm/*.js 636 bytes
    ./node_modules/@babel/runtime/helpers/esm/defineProperty.js 268 bytes [built] [code generated]
    ./node_modules/@babel/runtime/helpers/esm/typeof.js 368 bytes [built] [code generated]
  + 5 modules
artf commented 1 year ago

@mnutt did you try to reinstall with .lock file and node_modules deleted? Do you have the same issue if you run the build command?

bernesto commented 7 months ago

Ran into this issue when trying to build on a Window machine. I have not found a resolution yet. I suspect it is related to path differences on Windows vs. *nix OSs.

WARNING in ./src/common/index.ts 35:2-16
export 'default' (imported as 'Backbone') was not found in 'backbone' (module has no exports)
 @ ./src/editor/view/EditorView.ts 16:0-39 45:21-22 68:2-6
 @ ./src/editor/index.ts 60:0-43 866:30-40
 @ ./src/index.ts 13:0-30 61:25-31

WARNING in ./src/common/index.ts 43:2-21
export 'default' (imported as 'Backbone') was not found in 'backbone' (module has no exports)
 @ ./src/editor/view/EditorView.ts 16:0-39 45:21-22 68:2-6
 @ ./src/editor/index.ts 60:0-43 866:30-40
 @ ./src/index.ts 13:0-30 61:25-31

WARNING in ./src/common/index.ts 51:2-15
export 'default' (imported as 'Backbone') was not found in 'backbone' (module has no exports)
 @ ./src/editor/view/EditorView.ts 16:0-39 45:21-22 68:2-6
 @ ./src/editor/index.ts 60:0-43 866:30-40
 @ ./src/index.ts 13:0-30 61:25-31

WARNING in ./src/dom_components/model/Component.ts 1597:18-45
export 'Model' (imported as 'Model') was not found in 'backbone' (module has no exports)
 @ ./src/dom_components/index.ts 97:0-74 262:23-32 267:26-35 588:30-39 588:41-56
 @ ./src/editor/model/Editor.ts 91:0-52 138:4-20
 @ ./src/editor/index.ts 59:0-41 79:22-33
 @ ./src/index.ts 13:0-30 61:25-31

WARNING in ./src/dom_components/model/Component.ts 1625:25-53
export 'Model' (imported as 'Model') was not found in 'backbone' (module has no exports)
 @ ./src/dom_components/index.ts 97:0-74 262:23-32 267:26-35 588:30-39 588:41-56
 @ ./src/editor/model/Editor.ts 91:0-52 138:4-20
 @ ./src/editor/index.ts 59:0-41 79:22-33
 @ ./src/index.ts 13:0-30 61:25-31

WARNING in ./src/editor/model/Editor.ts 113:0-10
export 'default' (imported as 'Backbone') was not found in 'backbone' (module has no exports)
 @ ./src/editor/index.ts 59:0-41 79:22-33
 @ ./src/index.ts 13:0-30 61:25-31

WARNING in ./src/undo_manager/index.ts 76:23-34
export 'default' (imported as 'UndoManager') was not found in 'backbone-undo' (module has no exports)
 @ ./src/editor/model/Editor.ts 108:0-51 118:4-21
 @ ./src/editor/index.ts 59:0-41 79:22-33
 @ ./src/index.ts 13:0-30 61:25-31