New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic import inside getInitialProps and template literals #6032
Comments
Basically we have to inline all dynamic imports into the bundle for rendering. I'd like to start by pointing out using dynamic requires/import is generally a bad idea as it'll bundle way more than you expect / want to. Besides that feel free to investigate fixing this, as this is not going to be a blocker for the v8 release. The affected plugin is https://github.com/zeit/next.js/blob/canary/packages/next/build/webpack/plugins/serverless-plugin.ts |
Well this bug wasn't related to the issue I had with AWS after all. It's been 2 days now and tried everything I could think of but I still didn't manage to make it work with an api gateway event object. So.. I'll wait for someone to find a solution and keep deploying my 40mb app on s3 at every deploy 😬 ps: for this particular ticket, i'll take a look but I found a more suitable solution to get my translation file: a simple |
I have similar issue after upgrade from version
If NextJS 8 doesn't support this, do you have some advice how to make it work? 🤔 Or is there another better solution? |
import path from "path";
static async getInitialProps(props = {}) {
const lang = "en";
const i18n = eval(`require('${path.resolve(`../locale/${lang}.json`)}')`); |
Confirmed this works fine with Next.js 9 with the provided repository! Thanks 🙏 |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Bug report
Describe the bug
When i tried to use the new serverless feature (
v8.0.0-canary.3
) on AWS, I thought it was related to AWS itself (see #4496 (comment)). But I may have found an unrelated issue that can be reproduce locally.When you try to use
${lang}
inside theimport()
function, the server will break with this errorTypeError: undefined is not a function
and may be related to an undefined .map() function:Promise.all([].slice(1).map(undefined))
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
npm i
npm run build && node test.js
localhost:3000
pages/_app.js:8
and commentingpages/_app.js:11
Expected behavior
literal template should be parsed properly before importing the file (?)
Also, everything works fine locally with the
next
command.System information
Please let me know if I can help you further or if I'm completely missing something 😄
The text was updated successfully, but these errors were encountered: