From fa70e6c79d6888e9e0995792b09b0a97089bb137 Mon Sep 17 00:00:00 2001 From: riccardoperra Date: Wed, 2 Dec 2026 08:30:56 +0100 Subject: [PATCH 1/3] fix(angular): remove dangling sourceMappingURL from published bundle ng-packagr always emits source maps for FESM bundles. The build deleted the .map files but left the sourceMappingURL comment in tanstack-angular-table.mjs, so tools like the Vite dev server failed to load the missing map. Closes #6686 --- .../angular-table-no-source-map-comment.md | 5 +++ packages/angular-table/package.json | 2 +- .../scripts/remove-source-maps.js | 37 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 .changeset/angular-table-no-source-map-comment.md create mode 100644 packages/angular-table/scripts/remove-source-maps.js diff --git a/.changeset/angular-table-no-source-map-comment.md b/.changeset/angular-table-no-source-map-comment.md new file mode 100644 index 0000000000..1a4f47aeab --- /dev/null +++ b/.changeset/angular-table-no-source-map-comment.md @@ -0,0 +1,5 @@ +--- +'@tanstack/angular-table': patch +--- + +Remove the `sourceMappingURL` comment from the published `tanstack-angular-table.mjs` bundle. The package ships no source maps, so tools such as the Vite dev server failed to load the referenced `.map` file. diff --git a/packages/angular-table/package.json b/packages/angular-table/package.json index 43d7d9ee3e..9f16c124c9 100644 --- a/packages/angular-table/package.json +++ b/packages/angular-table/package.json @@ -54,7 +54,7 @@ "skills" ], "scripts": { - "build": "ng-packagr -p ng-package.json -c tsconfig.build.json && rimraf ./dist/package.json && find dist -name '*.map' -delete", + "build": "ng-packagr -p ng-package.json -c tsconfig.build.json && rimraf ./dist/package.json && node ./scripts/remove-source-maps.js", "build:types": "tsc --emitDeclarationOnly", "bench:flex-render": "vitest bench --run tests/flex-render/flex-render.bench.ts", "clean": "rimraf ./build && rimraf ./dist", diff --git a/packages/angular-table/scripts/remove-source-maps.js b/packages/angular-table/scripts/remove-source-maps.js new file mode 100644 index 0000000000..2ca75d8472 --- /dev/null +++ b/packages/angular-table/scripts/remove-source-maps.js @@ -0,0 +1,37 @@ +// ng-packagr always emits source maps for the FESM bundles and has no option +// to turn them off. +import { readFile, readdir, rm, writeFile } from 'node:fs/promises' +import { join } from 'node:path' +import { fileURLToPath } from 'node:url' + +const distDir = fileURLToPath(new URL('../dist/', import.meta.url)) +const sourceMappingUrlComment = /\s*\/\/# sourceMappingURL=\S+\.map\s*$/ + +async function listDistFiles() { + const entries = await readdir(distDir, { + recursive: true, + withFileTypes: true, + }) + + return entries + .filter((entry) => entry.isFile()) + .map((entry) => join(entry.parentPath, entry.name)) +} + +async function removeSourceMappingUrlComment(file) { + const content = await readFile(file, 'utf8') + const contentWithoutComment = content.replace(sourceMappingUrlComment, '\n') + + if (contentWithoutComment !== content) { + await writeFile(file, contentWithoutComment) + } +} + +const files = await listDistFiles() +const sourceMaps = files.filter((file) => file.endsWith('.map')) +const bundles = files.filter((file) => file.endsWith('.mjs')) + +await Promise.all([ + ...sourceMaps.map((file) => rm(file)), + ...bundles.map((file) => removeSourceMappingUrlComment(file)), +]) From 4fd7e310d53f41b29e2db5bb52569888b646c250 Mon Sep 17 00:00:00 2001 From: riccardoperra Date: Wed, 2 Dec 2026 08:35:43 +0100 Subject: [PATCH 2/3] refactor(angular): move dist/package.json cleanup into postbuild script --- packages/angular-table/package.json | 2 +- .../scripts/{remove-source-maps.js => postbuild.js} | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) rename packages/angular-table/scripts/{remove-source-maps.js => postbuild.js} (79%) diff --git a/packages/angular-table/package.json b/packages/angular-table/package.json index 9f16c124c9..c67154d794 100644 --- a/packages/angular-table/package.json +++ b/packages/angular-table/package.json @@ -54,7 +54,7 @@ "skills" ], "scripts": { - "build": "ng-packagr -p ng-package.json -c tsconfig.build.json && rimraf ./dist/package.json && node ./scripts/remove-source-maps.js", + "build": "ng-packagr -p ng-package.json -c tsconfig.build.json && node ./scripts/postbuild.js", "build:types": "tsc --emitDeclarationOnly", "bench:flex-render": "vitest bench --run tests/flex-render/flex-render.bench.ts", "clean": "rimraf ./build && rimraf ./dist", diff --git a/packages/angular-table/scripts/remove-source-maps.js b/packages/angular-table/scripts/postbuild.js similarity index 79% rename from packages/angular-table/scripts/remove-source-maps.js rename to packages/angular-table/scripts/postbuild.js index 2ca75d8472..1f9771247a 100644 --- a/packages/angular-table/scripts/remove-source-maps.js +++ b/packages/angular-table/scripts/postbuild.js @@ -1,5 +1,7 @@ +// Cleans up the ng-packagr output in dist. The package is published from its +// root package.json, so the package.json ng-packagr writes to dist is removed. // ng-packagr always emits source maps for the FESM bundles and has no option -// to turn them off. +// to turn them off, so the maps and their sourceMappingURL comments are removed. import { readFile, readdir, rm, writeFile } from 'node:fs/promises' import { join } from 'node:path' import { fileURLToPath } from 'node:url' @@ -27,6 +29,8 @@ async function removeSourceMappingUrlComment(file) { } } +await rm(join(distDir, 'package.json'), { force: true }) + const files = await listDistFiles() const sourceMaps = files.filter((file) => file.endsWith('.map')) const bundles = files.filter((file) => file.endsWith('.mjs')) From 396383c715320a6776d1ce20afde91d8a68c4735 Mon Sep 17 00:00:00 2001 From: riccardoperra Date: Wed, 2 Dec 2026 08:36:09 +0100 Subject: [PATCH 3/3] chore(angular): drop comments from postbuild script --- packages/angular-table/scripts/postbuild.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/angular-table/scripts/postbuild.js b/packages/angular-table/scripts/postbuild.js index 1f9771247a..349fdc287a 100644 --- a/packages/angular-table/scripts/postbuild.js +++ b/packages/angular-table/scripts/postbuild.js @@ -1,7 +1,3 @@ -// Cleans up the ng-packagr output in dist. The package is published from its -// root package.json, so the package.json ng-packagr writes to dist is removed. -// ng-packagr always emits source maps for the FESM bundles and has no option -// to turn them off, so the maps and their sourceMappingURL comments are removed. import { readFile, readdir, rm, writeFile } from 'node:fs/promises' import { join } from 'node:path' import { fileURLToPath } from 'node:url'