Skip to content
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

Quill delta / Angular 13 / Webpack error #3497

Closed
medi6 opened this issue Dec 1, 2021 · 26 comments
Closed

Quill delta / Angular 13 / Webpack error #3497

medi6 opened this issue Dec 1, 2021 · 26 comments

Comments

@medi6
Copy link
Contributor

medi6 commented Dec 1, 2021

Hi,

I was using Quill 2.0.0 pre 4 in Angular 12, very well, but now after Angular
update to 13, I've got a Webpack error :
ncaught SyntaxError: Unexpected token ':' at Object../node_modules/quill-delta/dist/Op.js (quill.js:1861) at nested_webpack_require_732 (quill.js:36) at eval (Delta.js:9) at Object../node_modules/quill-delta/dist/Delta.js (quill.js:1837) at nested_webpack_require_732 (quill.js:36) at eval (quill.js:6) at Module../core/quill.js (quill.js:611) at nested_webpack_require_732 (quill.js:36) at eval (core.js:2) at Module../core.js (quill.js:539)

I'm testing with older versions : it's ok with quill 1.3.7...
I don't know what has changed between the two Angular versions that causes this problem...

Thanks,

@mohammadsafia
Copy link

I faced the same issue when updating my angular app to the latest version (13)

@medi6
Copy link
Contributor Author

medi6 commented Dec 6, 2021

I faced the same issue when updating my angular app to the latest version (13)

\nsourceURL=webpack://Quill/./node_modules/quill-delta/dist/Op.js?"

I don't know why, but the line must be, as others :

\n//# sourceURL=webpack://Quill/./node_modules/quill-delta/dist/Op.js?"

If you know how to fix this....

Thanks,

@medi6
Copy link
Contributor Author

medi6 commented Dec 6, 2021

It's also ok with 2.0.0.prev1

@mohammadsafia
Copy link

It's also ok with 2.0.0.prev1

also, it's not working with this version, it works just with this 1.3.7 but all custom blot not working.

@jodinathan
Copy link

It's also ok with 2.0.0.prev1

@medi6 is there any info regarding this new version?

@mwijnands
Copy link

It works in angular 12.2.0 and breaks in 12.2.1. I think it has something to do with webpack being updated in that version of angular-builder.

@ErikYu
Copy link

ErikYu commented Mar 8, 2022

One way to solve this issue is to make sourceMap=false. But this should only be a workaround.
So will this issue be solved in the future?

@ErikYu
Copy link

ErikYu commented Mar 8, 2022

Another way is stop using import. Instead we can include quilljs in angular.json.
"scripts": [ "node_modules/quill/dist/quill.js" ]
Then use declare const Quill: any; in component file.

@JLudwig2552
Copy link

Looks like it's related to this: parcel-bundler/parcel#3543

@qlombat
Copy link

qlombat commented Oct 6, 2022

Is there any solution, I still have the issue and the sourceMap set to false is not a convenient fix.

@KillerCodeMonkey
Copy link

same thing with v2.0.0-beta.0

@benbro
Copy link
Contributor

benbro commented Dec 8, 2023

Make sure you have the specific beta version in your package.json: "quill": "2.0.0-beta.0"

@KillerCodeMonkey
Copy link

As i said. I got the error with angular 17 and the 2.0.0 beta.0 and yes I installed the latest typings As well.

As the creator and maintainer i would like to create a beta Version of my package as well.

Ng-packagr and Karma test bundler are thowing this error.
And the workaround to use quilljs as external Script is no Option for me as package maintainer.

@luin
Copy link
Member

luin commented Dec 9, 2023

@KillerCodeMonkey Is there a repo for reproduction so I can test?

@KillerCodeMonkey
Copy link

KillerCodeMonkey commented Dec 9, 2023

sure: i created a draft pr for my ngx-quill package. there you see my changes and even the failing ci with default angular test runner and builder.

KillerCodeMonkey/ngx-quill#1778

It throws the same error.

https://github.com/KillerCodeMonkey/ngx-quill/actions/runs/7149782730/job/19472368497?pr=1778

Keep in mind this is PR is not final. i just started the transition and fixed the Delta typing and tried to run the test cases to see what fails or changed.

@benbro
Copy link
Contributor

benbro commented Dec 9, 2023

Run npm ls inside your project and check the installed Quill version. If it's not the correct version replace "quill": "^2.0.0-beta.0", with "quill": "2.0.0-beta.0", without the caret (^) in package.json. Quill 2.0 is a typescript project. You probably don't need @types/quill.

@KillerCodeMonkey
Copy link

@benbro you are right. it was late and i missed the caret thing. but strange the dev.4 is marked as "latest" release instead of the "beta.0"

i made some changes like adding custom webpack loader for karma tests to handle inline svgs and changed insertContent calls with html. my tests are running without quite heavy adoptions.

If someone is interested -> checkout the linked pr above

@KillerCodeMonkey
Copy link

anyone has an idea how to get the inlined svg icons working with angular 17? vite just puts the paths to the images into the dom instead the svgs.

KillerCodeMonkey/ngx-quill-example#1632

@pablopla
Copy link

pablopla commented Dec 10, 2023

The svg files are inline in the compiled node_modules/quill/dist/quill.js so we shouldn't get an error. import Quill from 'quill'; imports the raw files instead of the compiled file from dist/quill.js

This should be "main": "dist/quill.js", instead of "main": "quill.js",
https://github.com/quilljs/quill/blob/develop/packages/quill/package.json#L7

Reported here: #3928

@KillerCodeMonkey
Copy link

strange because in general it should check the package.json of the node_module and grad the correct path from there.

@EdManukyan
Copy link

@KillerCodeMonkey any updates when the ngx quill have quill 2.0 support? Are you planing to upgrade after the stable quill 2.0 is released ?

@KillerCodeMonkey
Copy link

There is a pr with quill rc0 Support and I already Released a beta Version.

But there are some Things to know:

  • I Import quill from the cjs, because the in the other modules/bundles svg files are inlined and angulars esbuild is not working with That
  • In General most no third Party modules/Blots are not working

Feel free to try

@pablopla
Copy link

pablopla commented Jan 6, 2024

@KillerCodeMonkey How do you import quill from cjs?

There is support for custom esbuild loaders in Angular 17.1.0-rc.0. I've tried adding SVG loader to angular.json:

"architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:application",
          "options": {
            "loader": {
              ".svg": "text"
            },

But I only get the SVG path instead of its content:

<button type="button" class="ql-bold" aria-pressed="false" aria-label="bold">/@fs/home/u/project/node_modules/quill/assets/icons/bold.svg</button>

Do you know if the issue is on Quill side or Angular side?

@KillerCodeMonkey
Copy link

I import it in my Service from 'quill/dist/quill.js'

@KillerCodeMonkey
Copy link

it is working with the latest experimental build of quilljs. i released a new beta version of ngx-quill and updated my quill 2 beta branch of the example repository, if someone is interested.

@benbro
Copy link
Contributor

benbro commented Jan 29, 2024

Closing based on @KillerCodeMonkey comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

13 participants