未验证 提交 023863d9 编写于 作者: J Joe Haddad 提交者: GitHub

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

This reverts commit 67f7cf56.
上级 004319fa
......@@ -55,18 +55,11 @@ export default function nextPageConfig({
path: NodePath<BabelTypes.ExportNamedDeclaration>,
state: any
) {
// Skip if the file will be dropped
if (state.bundleDropped) {
if (state.bundleDropped || !path.node.declaration) {
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 config: PageConfig = {}
// drop SSR Exports for client bundles
if (
......@@ -85,11 +78,7 @@ export default function nextPageConfig({
if (!declarations) {
return
}
const config: PageConfig = {}
for (let dIndex = 0; dIndex < declarations.length; ++dIndex) {
const declaration = declarations[dIndex]
for (const declaration of declarations) {
if (declaration.id.name !== 'config') {
continue
}
......@@ -113,11 +102,6 @@ export default function nextPageConfig({
config[name] = prop.value.value
}
}
declarations.splice(dIndex, 1)
if (declarations.length === 0) {
path.remove()
}
}
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', () => {
it('builds without error when export const config is used outside page', async () => {
const { stderr } = await nextBuild(appDir, undefined, { stderr: true })
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 () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册