-
-
Notifications
You must be signed in to change notification settings - Fork 117
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
Angular esbuild error on DomPurify with rowDetailView and no pre/post template #1362
Comments
DOMPurify doesn't work with So I'm afraid that there is no fix, I did try to use You could maybe try this old Rollup patch that I used in the past for other dependency like MomentJS, this might work (you could submit a PR if it does) // patch to fix rollup "moment has no default export" issue,
// documented at: https://github.com/rollup/rollup/issues/670
import * as dompurify_ from dompurify';
const DOMPurify = (dompurify_ as any)['default'] || dompurify_; in summary, it's a DOMPurify problem that existed forever (they're still using a CommonJS approach and even if they tried, they still haven't found the best approach) EDIT I was actually using that patch in Slickgrid-Universal 3.x but stop using it in 4.x. I might have to put it back in place though at least in here, see this line for 3.x |
Ah, sorry, I totally didn't think about actually running Doing that gives:
Which is odd, since that flag seems to be set. I'm not sure about your workaround though, I'm a bit hesitant to introduce a hack. Taking a step back and starting fresh from https://angular.io/guide/creating-libraries
Add to import DOMPurify from 'dompurify';
...
ngOninit() {
const clean = DOMPurify.sanitize('<script>alert("Hello World!")</script>');
console.log(clean);
} So I
So I add
Now I just need to figure out why in Angular-Slickgrid the |
One step further. Adding
and adding
to Angular-Slickgrid and changing in
I'm not yet sure about all the details here (settings in the tsconfig.lib.json files) ...and also need to test out the produced package. |
Just
Also I tested the produced package in our app, all looks good :) PR incoming... |
…sbuild error on DomPurify with rowDetailView and no pre/post template #1362
😮 wow that is a lot of investigation and knowing that ng-packgr use their tsconfig explains why it worked in all my other projects SlickGrid project except in Angular. I was totally unaware of this side effect by ng-packagr. Your work here is really awesome in finding a workable fix 👏🏻 |
Describe the bug
Hi!
Angular esbuild with rowDetailView gives a runtime error:
With esbuild namespace imports are not supported: https://angular.io/guide/esbuild#esm-default-imports-vs-namespace-imports
import * as DOMPurify from 'dompurify'; should be changed to
import DOMPurify from 'dompurify';
Reproduction
Change
"builder": "@angular-devkit/build-angular:browser"
to"builder": "@angular-devkit/build-angular:browser-esbuild"
inangular.json
yarn start
( notice the lightning fast build time 😄 )Browse to: http://localhost:4300/#/rowdetail
Expand the first row
Notice expansion doesn't work and console log shows the error.
Change to
import DOMPurify from 'dompurify';
inslickRowDetailView.ts
and save the file.Wait a second for rebuild, expand first row, notice it works :)
We use this workaround for now:
I can submit a PR to fix this one liner if you want?
Expectation
No response
Environment Info
Validations
The text was updated successfully, but these errors were encountered: