Skip to content

Commit fe36d1c

Browse files
authored
chore: Test treeshaking on built output, instead of source code (#2248)
1 parent fab7c02 commit fe36d1c

13 files changed

Lines changed: 34 additions & 18 deletions

apps/treeshake-test/generateTests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ async function generateTestFiles() {
4545

4646
for (const { export: exportName, from, log } of imports) {
4747
const testContent = `
48-
import { ${exportName} } from '${from}';
49-
console.log(typeof ${log});
48+
import { ${exportName} } from '${from}/$built$';
49+
console.log(${log});
5050
`;
5151

5252
const fileName = `${log}_from_${from.replaceAll('/', '')}.ts`;

apps/treeshake-test/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "module",
77
"scripts": {
88
"generate-tests": "tsx generateTests.ts",
9-
"test": "node runTests.ts"
9+
"test": "pnpm run --filter typegpu build && node runTests.ts"
1010
},
1111
"dependencies": {
1212
"typegpu": "workspace:*",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import * as d from 'typegpu/data';
1+
import * as d from 'typegpu/data/$built$';
22

33
console.log(d);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { sizeOf } from 'typegpu/data';
1+
import { sizeOf } from 'typegpu/data/$built$';
22

33
console.log(sizeOf);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import * as d from 'typegpu/data';
1+
import * as d from 'typegpu/data/$built$';
22

33
console.log(d.sizeOf);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import tgpu from 'typegpu';
2-
import * as d from 'typegpu/data';
3-
import * as std from 'typegpu/std';
1+
import tgpu from 'typegpu/$built$';
2+
import * as d from 'typegpu/data/$built$';
3+
import * as std from 'typegpu/std/$built$';
44

55
console.log(tgpu, d, std);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import tgpu from 'typegpu';
2-
import * as d from 'typegpu/data';
3-
import * as std from 'typegpu/std';
1+
import tgpu from 'typegpu/$built$';
2+
import * as d from 'typegpu/data/$built$';
3+
import * as std from 'typegpu/std/$built$';
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import * as std from 'typegpu/std';
1+
import * as std from 'typegpu/std/$built$';
22

33
console.log(std);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { add } from 'typegpu/std';
1+
import { add } from 'typegpu/std/$built$';
22

33
console.log(add(1, 2));
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import * as std from 'typegpu/std';
1+
import * as std from 'typegpu/std/$built$';
22

33
console.log(std.add(1, 2));

0 commit comments

Comments
 (0)