`Re-exporting all exports from a page is disallowed` occurs on non-page file when using `pageExtensions`
See original GitHub issueWhat version of Next.js are you using?
12.0.7
What version of Node.js are you using?
14.176
What browser are you using?
Chrome
What operating system are you using?
macOS
How are you deploying your application?
Vercel
Describe the Bug
Re-exporting all exports from a page is disallowed
Have been rewritten with Rust but it seems to not care of pageExtensions
option in next.config.js.
Expected Behavior
Re-exporting all exports from a page is disallowed
Error shouldn’t occur on non-page files under /pages
when using pageExtensions
option.
To Reproduce
Create a fresh Next project with the pageExtensions
set to ['page.tsx', 'page.ts']
.
The pages folder looks like:
pages/
users/
index.page.tsx // import { UserComments } from './components';
components/
index.tsx // <= re-export all: export * from './UserComments';
UserComments.tsx // contain a named export: export cont UserComments = () => <h1>User comments</h1>
package.json
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
Next js - disable server side rendering on some pages
Lazy load the component and disable SSR: https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr
Read more >next - npm
Every import you declare gets bundled and served with each page. That means pages never load unnecessary code! import cowsay from ...
Read more >page extraction is not allowed in the source pdf documents
Solved: I am trying to combine multiple pdf files into 1 file. I keep getting this error - "page extraction is not allowed...
Read more >Rewrites - next.config.js
fallback rewrites are checked/applied, these are applied before rendering the 404 page and after dynamic routes/all static assets have been checked. If you...
Read more >Yii2-export: exported CSV/XLS contains html from page
I'm using yii2-export and it's almost all fine, except that I get some html of the page inside the exported file in Excel/CSV....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi, I was just checking the code to solve this issue for
next-page-disallow-re-export-all-exports
plugin. and I found one issue here https://github.com/vercel/next.js/blob/canary/packages/next/build/babel/loader/get-config.ts#L98actual behaviour :
isPageFile
is true forcomponents/index.tsx
because it is inside pages folder. expected behaviour :isPageFile
should be false here forcomponents/index.tsx
because ofpageExtensions
I was just wondering from where I can get
pageExtensions
to pass it to getCacheCharacteristics ?UPDATE: I found it for babel config. I am now exploring code for swc loader
UPDATE: raised PR
It’s a pity we didn’t have a response from anyone from the contributors. It was working, them a new feature or something introduced this bug and it’s there forever. I know there’s tons of issues opened, sprints on going but it has been 3 months.
I have to adapt my codebase as workaround for this problem (removing index.ts files even thought they don’t have
.page
extension).