-
-
Notifications
You must be signed in to change notification settings - Fork 763
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
E2E test should use the local version #2012
Conversation
@adrai before merging I would like your opinion on this. TLDR: we make examples a bit dirty, we gain confidence on CI. |
@@ -59,6 +59,8 @@ | |||
"example:ssg:prod": "npm run build:example:ssg && cd examples/ssg && npm run start", | |||
"cypress": "cypress run --config-file cypress/cypress.json", | |||
"test": "npm-run-all -s check-types clean build build:example:simple && NODE_ENV=test jest --maxWorkers=1 --silent", | |||
"move-build-to-examples?": "Hack: see # @link https://github.com/i18next/next-i18next/pull/2012", | |||
"move-build-to-examples": "rimraf ./examples/*/node_modules/next-i18next && cpy './package.json' './*.js' './*.ts' './dist' ./examples/simple/node_modules/next-i18next && cpy './package.json' './*.js' './*.ts' './dist' ./examples/ssg/node_modules/next-i18next", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dirty part 😮💨 till better options emerges.
@@ -14,7 +14,7 @@ | |||
"dependencies": { | |||
"i18next": "^22.0.4", | |||
"next": "^13.0.2", | |||
"next-i18next": "^12.1.0", | |||
"next-i18next": "file:../..", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the example less copy/pastable. But I don't think devs would use our package.json as is when looking at the example.
I think i can live with that. |
Thanks I'll merge and continue a bit tomorrow. Just want to be sure the current master has no regression. I'll ping when I'm confident. |
Before this PR our e2e tests and example install were using the last published version on npm.
This defeats the CI confidence.
As not everything is perfect, I haven't been able to simply use the npm
link:../..
protocol to create a symlink to the root (where the dist folder resides). The main reason is:Code like this:
next-i18next/src/serverSideTranslations.ts
Lines 26 to 29 in 0c796cb
Will be transpiled by babel (cjs) to this
And it won't work in a webpack context:
require(s)
will fail in some situations. (I've tested a lot of options, like webpackIgnores...). Changing this is a significant work and is prone to errors (webpack have limits). Example of error:See also #1917 (comment) and this https://github.com/bryantobing12/layout-reproduce-i18next/pull/1/files#diff-b09c1f3451013e7a5ceffec2636d3175563b96a911a9a91c1fe08d5110a7a1b0
My opinion (for the future):
@adrai FYI: We shouldn't play with that and always require the consuming code to provide the config (especially next 13 turbopack, etc). For example appWithTranslation and serverSideTranslations must receive the config file path. Otherwise it won't work (in monorepo situations for example). There's options to do so (like creating a new method for ssr and make the second parameter of appWithTranslation required).
In order to move forward, I'll let this for a later time.
PS: This P/R introduce more complexity for the examples. But I feel for now it's a good trade-off. I don't think people will use blindly our package.json as is (with the file:../...). The gain for us is quality.