diff --git a/.changeset/olive-pugs-shave.md b/.changeset/olive-pugs-shave.md new file mode 100644 index 000000000..1fc7649ef --- /dev/null +++ b/.changeset/olive-pugs-shave.md @@ -0,0 +1,5 @@ +--- +"@solidjs/start": patch +--- + +keep TypeScript namespace members in route files during production builds diff --git a/packages/start/src/config/fs-routes/tree-shake.ts b/packages/start/src/config/fs-routes/tree-shake.ts index db63a3329..61824e24f 100644 --- a/packages/start/src/config/fs-routes/tree-shake.ts +++ b/packages/start/src/config/fs-routes/tree-shake.ts @@ -147,6 +147,11 @@ function treeShakeTransform({ types: t }: typeof Babel): PluginObj { if (!state.opts.pick) { return; } + // Only module-level exports are route exports; `export` inside a + // TS namespace/module block is unrelated to the pick list. + if (!exportNamedPath.parentPath.isProgram()) { + return; + } const specifiers = exportNamedPath.get("specifiers"); if (specifiers.length) { specifiers.forEach(s => {