Unable to build Next if we export a config variable in a file
Assume it's a bug as I had no problem with Next 8, but was unable to build / run after updating to Next 9
export const config = "someValue" will cause a webpack TypeError: declaration.init.properties is not iterable error.
I assume config is now a reserved keyword as I had no problem before.
So not really difficult to correct, as you only have to change the export var name, but it can save hours if someone like me was exporting a config variable
Please provide a full reproduction.
We are experiencing the same problem. We renamed our export to appConfig and now it has started working.
Sorry, but this export is now a reserved value by Next.js. We'll update the UPGRADING.md doc to reflect this.
I just noticed the notes in the UPGRADING doc say:
You may no longer export a custom variable named config from a page
We were seeing this issue in a non-page file, one that was being required by a page file (indirectly).
Is this expected behaviour? Or should it only be the page which is not allowed to export a config object (this is what I understand as being correct right now). Why would exporting from a non-page file conflict with anything?
I this is expected behaviour then I think the upgrading doc should be updated.
Trying to upgrade to next 9 here as well and getting the same issue from an external package. (although transpiled by next.js)
Our specific issue only happens when we transpile prebid.js
https://codesandbox.io/s/hello-world-rz2lr?fontsize=14
edit: For anyone for my very specific prebid issue I worked around it (probably in a better way even) by removing the custom babel config and not using next-transpile-modules, and then instead add this to next.config.js:
const prebidOptions = require('prebid.js/.babelrc.js')
config.module.rules.push({
test: /\.js$/,
include: new RegExp(`\\${path.sep}prebid.js`),
use: {
loader: 'babel-loader',
options: {
...prebidOptions,
sourceType: 'unambiguous'
}
}
})
Ah, interesting. It should only affect ./page/ files -- not dependencies or imports from a page.