Unverified Commit 023863d9 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Revert "Remove `config` export (#8895)" (#8982)

This reverts commit 67f7cf56.
parent 004319fa
...@@ -55,18 +55,11 @@ export default function nextPageConfig({ ...@@ -55,18 +55,11 @@ export default function nextPageConfig({
path: NodePath<BabelTypes.ExportNamedDeclaration>, path: NodePath<BabelTypes.ExportNamedDeclaration>,
state: any state: any
) { ) {
// Skip if the file will be dropped if (state.bundleDropped || !path.node.declaration) {
if (state.bundleDropped) {
return return
} }
// Bail out of `export { a, b, c };` case.
// We should probably support this.
if (!path.node.declaration) {
return
}
const { declarations, id } = path.node.declaration as any const { declarations, id } = path.node.declaration as any
const config: PageConfig = {}
// drop SSR Exports for client bundles // drop SSR Exports for client bundles
if ( if (
...@@ -85,11 +78,7 @@ export default function nextPageConfig({ ...@@ -85,11 +78,7 @@ export default function nextPageConfig({
if (!declarations) { if (!declarations) {
return return
} }
for (const declaration of declarations) {
const config: PageConfig = {}
for (let dIndex = 0; dIndex < declarations.length; ++dIndex) {
const declaration = declarations[dIndex]
if (declaration.id.name !== 'config') { if (declaration.id.name !== 'config') {
continue continue
} }
...@@ -113,11 +102,6 @@ export default function nextPageConfig({ ...@@ -113,11 +102,6 @@ export default function nextPageConfig({
config[name] = prop.value.value config[name] = prop.value.value
} }
} }
declarations.splice(dIndex, 1)
if (declarations.length === 0) {
path.remove()
}
} }
if (config.amp === true) { if (config.amp === true) {
......
module.exports = { generateBuildId: () => 'test-page-config' }
import { config as hello } from '../something'
import { config as world } from '../config'
export const config = { _unknownKey: 'THIS_VALUE_SHOULD_BE_GONE' }
export default () => (
<p>
{hello} {world}
</p>
)
...@@ -13,16 +13,6 @@ describe('Page Config', () => { ...@@ -13,16 +13,6 @@ describe('Page Config', () => {
it('builds without error when export const config is used outside page', async () => { it('builds without error when export const config is used outside page', async () => {
const { stderr } = await nextBuild(appDir, undefined, { stderr: true }) const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
expect(stderr).not.toMatch(/Failed to compile\./) expect(stderr).not.toMatch(/Failed to compile\./)
const clientFileOutput = await fs.readFile(
join(
appDir,
'.next/static/test-page-config',
'pages/check-client-remove.js'
),
'utf8'
)
expect(clientFileOutput).not.toMatch('THIS_VALUE_SHOULD_BE_GONE')
}) })
it('shows valid error on invalid page config', async () => { it('shows valid error on invalid page config', async () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment