Skip to content

Commit

Permalink
Move sourcemaps out of distributions at build
Browse files Browse the repository at this point in the history
  • Loading branch information
jmhobbs committed Oct 7, 2024
1 parent 26cb8de commit ac9aced
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ node
storybook-out
coverage
package.json.backup
sourcemaps
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"isChromatic.d.ts"
],
"scripts": {
"build": "clean-package && tsup && clean-package restore",
"build": "clean-package && tsup && ./scripts/moveSourceMaps.mjs && clean-package restore",
"build-storybook": "storybook build --stats-json",
"build-test-storybook": "cross-env SMOKE_TEST=true storybook build -o test-storybook --stats-json",
"build-subdir": "cd subdir ; yarn build ; cd ..",
Expand Down
26 changes: 26 additions & 0 deletions scripts/moveSourceMaps.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env node

import fs from 'node:fs';

async function main() {
fs.mkdirSync('sourcemaps', { recursive: true });
for (const file of fs.readdirSync('sourcemaps')) {
fs.unlinkSync(`sourcemaps/${file}`);

Check warning on line 8 in scripts/moveSourceMaps.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/moveSourceMaps.mjs#L8

The application dynamically constructs file or path information.
}

for (const file of fs.readdirSync('dist')) {
if (file.endsWith('.map')) {
fs.copyFileSync(`dist/${file}`, `sourcemaps/${file}`);
fs.unlinkSync(`dist/${file}`);

Check warning on line 14 in scripts/moveSourceMaps.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/moveSourceMaps.mjs#L14

The application dynamically constructs file or path information.
}
}

for (const file of fs.readdirSync('action')) {
if (file.endsWith('.map')) {
fs.copyFileSync(`action/${file}`, `sourcemaps/${file}`);
fs.unlinkSync(`action/${file}`);

Check warning on line 21 in scripts/moveSourceMaps.mjs

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

scripts/moveSourceMaps.mjs#L21

The application dynamically constructs file or path information.
}
}
}

main();

0 comments on commit ac9aced

Please sign in to comment.