Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/angular-table-no-source-map-comment.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion packages/angular-table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 && 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",
Expand Down
37 changes: 37 additions & 0 deletions packages/angular-table/scripts/postbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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)
}
}

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'))

await Promise.all([
...sourceMaps.map((file) => rm(file)),
...bundles.map((file) => removeSourceMappingUrlComment(file)),
])
Loading