diff --git a/angular.json b/angular.json index f16b6741..545fc73e 100644 --- a/angular.json +++ b/angular.json @@ -33,8 +33,7 @@ "buildOptimizer": false, "sourceMap": true, "optimization": false, - "namedChunks": true, - "allowedCommonJsDependencies": ["dompurify"] + "namedChunks": true }, "configurations": { "production": { diff --git a/dompurify.patch b/dompurify.patch new file mode 100644 index 00000000..e4f2ce10 --- /dev/null +++ b/dompurify.patch @@ -0,0 +1,11 @@ +--- node_modules/dompurify/package.json.old 2022-08-11 10:15:37.122839016 +0100 ++++ node_modules/dompurify/package.json 2022-08-11 10:15:53.130662100 +0100 +@@ -17,7 +17,7 @@ + "test:ci": "cross-env NODE_ENV=test BABEL_ENV=rollup npm run test:jsdom && npm run test:karma -- --log-level error --reporters dots --single-run --shouldTestOnBrowserStack=\"${TEST_BROWSERSTACK}\" --shouldProbeOnly=\"${TEST_PROBE_ONLY}\"", + "test": "cross-env NODE_ENV=test BABEL_ENV=rollup npm run lint && npm run test:jsdom && npm run test:karma -- --browsers Chrome" + }, +- "main": "dist/purify.cjs.js", ++ "main": "dist/purify.es.js", + "module": "dist/purify.es.js", + "browser": "dist/purify.js", + "files": [ diff --git a/dompurify_repro.sh b/dompurify_repro.sh new file mode 100755 index 00000000..823c4acc --- /dev/null +++ b/dompurify_repro.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +set -e + +(cd node_modules/dompurify && npx -p typescript tsc dist/*.js --declaration --allowJs --emitDeclarationOnly --outDir dist) + +patch -u node_modules/dompurify/package.json -i dompurify.patch + +npx ng build --configuration production | grep dompurify + diff --git a/src/app/markdown/markdownify.pipe.ts b/src/app/markdown/markdownify.pipe.ts index b4bc9536..1dfaecb7 100644 --- a/src/app/markdown/markdownify.pipe.ts +++ b/src/app/markdown/markdownify.pipe.ts @@ -15,7 +15,7 @@ */ import { Pipe, PipeTransform } from '@angular/core'; -import * as DOMPurify from 'dompurify'; +import DOMPurify from 'dompurify'; import snarkdown from 'snarkdown'; @Pipe({ diff --git a/tsconfig.json b/tsconfig.json index 208f623a..d499ba94 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,8 @@ "importHelpers": true, "target": "es2020", "module": "es2020", - "lib": ["es2018", "dom"] + "lib": ["es2018", "dom"], + "traceResolution": true }, "angularCompilerOptions": { "strictInjectionParameters": true,