Skip to content

Commit

Permalink
Disallow wildcard export in server entries (#46710)
Browse files Browse the repository at this point in the history
Similar to client entry files, we don't allow `export *` in server entries as well because we can't statically analyze all the export types in SWC.

Fixes NEXT-490

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm build && pnpm lint`
- [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
  • Loading branch information
shuding committed Mar 3, 2023
1 parent f7bfaff commit 9acbf6e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/next-swc/crates/core/src/server_actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ impl<C: Comments> VisitMut for ServerActions<C> {
disallowed_export_span = *span;
}
},
ModuleItem::ModuleDecl(ModuleDecl::ExportAll(ExportAll { span, .. })) => {
disallowed_export_span = *span;
}
_ => {}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use server';

export * from 'foo'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* __next_internal_action_entry_do_not_use__ */ export * from 'foo';
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

x Only async functions are allowed to be exported in a "use server" file.
,-[input.js:2:1]
2 |
3 | export * from 'foo'
: ^^^^^^^^^^^^^^^^^^^
`----

0 comments on commit 9acbf6e

Please sign in to comment.