-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Switch to .cjs PostCSS config #58380
Conversation
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
1 similar comment
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
Allow CI Workflow Run
Note: this should only be enabled once the PR is ready to go and can only be enabled by a maintainer |
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.
Thank you for submitting a
@karlhorky I think we just need to handle the conflicts and we'll good to |
@samcx thanks for the review and approval! Just merged in canary, it should be ready for merging now. |
Tests Passed |
Stats from current PRDefault Build (Increase detected
|
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
buildDuration | 14s | 14.1s | N/A |
buildDurationCached | 7.5s | 6.2s | N/A |
nodeModulesSize | 198 MB | 198 MB | ✓ |
nextStartRea..uration (ms) | 435ms | 434ms | N/A |
Client Bundles (main, webpack)
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
2453-HASH.js gzip | 30.5 kB | 30.5 kB | N/A |
3304.HASH.js gzip | 181 B | 181 B | ✓ |
3f784ff6-HASH.js gzip | 53.7 kB | 53.7 kB | N/A |
8299-HASH.js gzip | 5.04 kB | 5.04 kB | N/A |
framework-HASH.js gzip | 45.2 kB | 45.2 kB | ✓ |
main-app-HASH.js gzip | 241 B | 243 B | N/A |
main-HASH.js gzip | 32.2 kB | 32.2 kB | N/A |
webpack-HASH.js gzip | 1.68 kB | 1.68 kB | N/A |
Overall change | 45.4 kB | 45.4 kB | ✓ |
Legacy Client Bundles (polyfills)
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
polyfills-HASH.js gzip | 31 kB | 31 kB | ✓ |
Overall change | 31 kB | 31 kB | ✓ |
Client Pages
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
_app-HASH.js gzip | 196 B | 197 B | N/A |
_error-HASH.js gzip | 184 B | 184 B | ✓ |
amp-HASH.js gzip | 505 B | 505 B | ✓ |
css-HASH.js gzip | 324 B | 325 B | N/A |
dynamic-HASH.js gzip | 2.5 kB | 2.5 kB | N/A |
edge-ssr-HASH.js gzip | 258 B | 258 B | ✓ |
head-HASH.js gzip | 352 B | 352 B | ✓ |
hooks-HASH.js gzip | 370 B | 371 B | N/A |
image-HASH.js gzip | 4.21 kB | 4.21 kB | ✓ |
index-HASH.js gzip | 259 B | 259 B | ✓ |
link-HASH.js gzip | 2.67 kB | 2.67 kB | N/A |
routerDirect..HASH.js gzip | 314 B | 312 B | N/A |
script-HASH.js gzip | 386 B | 386 B | ✓ |
withRouter-HASH.js gzip | 309 B | 309 B | ✓ |
1afbb74e6ecf..834.css gzip | 106 B | 106 B | ✓ |
Overall change | 6.57 kB | 6.57 kB | ✓ |
Client Build Manifests
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
_buildManifest.js gzip | 481 B | 484 B | N/A |
Overall change | 0 B | 0 B | ✓ |
Rendered Page Sizes
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
index.html gzip | 530 B | 528 B | N/A |
link.html gzip | 540 B | 540 B | ✓ |
withRouter.html gzip | 524 B | 522 B | N/A |
Overall change | 540 B | 540 B | ✓ |
Edge SSR bundle Size
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
edge-ssr.js gzip | 95.1 kB | 95.1 kB | N/A |
page.js gzip | 3.07 kB | 3.07 kB | N/A |
Overall change | 0 B | 0 B | ✓ |
Middleware size
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
middleware-b..fest.js gzip | 625 B | 624 B | N/A |
middleware-r..fest.js gzip | 151 B | 151 B | ✓ |
middleware.js gzip | 25.5 kB | 25.5 kB | N/A |
edge-runtime..pack.js gzip | 839 B | 839 B | ✓ |
Overall change | 990 B | 990 B | ✓ |
Next Runtimes
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
app-page-exp...dev.js gzip | 171 kB | 171 kB | ✓ |
app-page-exp..prod.js gzip | 96.5 kB | 96.5 kB | ✓ |
app-page-tur..prod.js gzip | 98.3 kB | 98.3 kB | ✓ |
app-page-tur..prod.js gzip | 92.7 kB | 92.7 kB | ✓ |
app-page.run...dev.js gzip | 149 kB | 149 kB | ✓ |
app-page.run..prod.js gzip | 91.2 kB | 91.2 kB | ✓ |
app-route-ex...dev.js gzip | 21.3 kB | 21.3 kB | ✓ |
app-route-ex..prod.js gzip | 15 kB | 15 kB | ✓ |
app-route-tu..prod.js gzip | 15 kB | 15 kB | ✓ |
app-route-tu..prod.js gzip | 14.8 kB | 14.8 kB | ✓ |
app-route.ru...dev.js gzip | 21 kB | 21 kB | ✓ |
app-route.ru..prod.js gzip | 14.8 kB | 14.8 kB | ✓ |
pages-api-tu..prod.js gzip | 9.52 kB | 9.52 kB | ✓ |
pages-api.ru...dev.js gzip | 9.8 kB | 9.8 kB | ✓ |
pages-api.ru..prod.js gzip | 9.52 kB | 9.52 kB | ✓ |
pages-turbo...prod.js gzip | 22.3 kB | 22.3 kB | ✓ |
pages.runtim...dev.js gzip | 22.9 kB | 22.9 kB | ✓ |
pages.runtim..prod.js gzip | 22.3 kB | 22.3 kB | ✓ |
server.runti..prod.js gzip | 50.5 kB | 50.5 kB | ✓ |
Overall change | 948 kB | 948 kB | ✓ |
build cache Overall increase ⚠️
vercel/next.js canary | karlhorky/next.js patch-6 | Change | |
---|---|---|---|
0.pack gzip | 1.56 MB | 1.56 MB | |
index.pack gzip | 105 kB | 105 kB | N/A |
Overall change | 1.56 MB | 1.56 MB |
Diff details
Diff for middleware.js
Diff too large to display
@samcx seems like one test is timing out here, is it easy to re-run it? Or if it's an unrelated test failure, should it just be ignored and the PR merged as-is? |
@karlhorky I was looking into the test—could just be a flaky cache issue, so I was looking into it. No worries about merging the latest canary—I'm still taking a look! |
@samcx thanks for the review and merge! I can confirm that this is working with I'm assuming that this will be released in ➜ p mkdir aa
➜ p cd aa
➜ aa pnpm create next-app@canary . --app --no-eslint --no-src-dir --import-alias @/\* --tailwind
.../Library/pnpm/store/v3/tmp/dlx-77997 | +1 +
.../Library/pnpm/store/v3/tmp/dlx-77997 | Progress: resolved 1, reused 0, downloaded 1, added 1, done
✔ Would you like to use TypeScript? … No / Yes
Creating a new Next.js app in /Users/k/p/aa.
Using pnpm.
Initializing project with template: app-tw
Installing dependencies:
- react
- react-dom
- next
Installing devDependencies:
- postcss
- tailwindcss
Progress: resolved 85, reused 74, downloaded 0, added 0
Downloading registry.npmjs.org/next/14.2.0-canary.23: 20.49 MB/20.49 MB, done
Packages: +124
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Downloading registry.npmjs.org/@next/swc-darwin-arm64/14.2.0-canary.23: 36.71 MB/36.71 MB, done
Progress: resolved 132, reused 121, downloaded 3, added 124, done
dependencies:
+ next 14.2.0-canary.23
+ react 18.2.0
+ react-dom 18.2.0
devDependencies:
+ postcss 8.4.35
+ tailwindcss 3.4.1
Done in 7.5s
Initialized a git repository.
Success! Created aa at /Users/k/p/aa
➜ aa git:(main) ls -al
total 120
drwxr-xr-x 14 k staff 448 Mar 15 11:02 .
drwxr-xr-x 63 k staff 2016 Mar 15 11:02 ..
drwxr-xr-x 12 k staff 384 Mar 15 11:02 .git
-rw-r--r-- 1 k staff 391 Mar 15 11:02 .gitignore
-rw-r--r-- 1 k staff 1382 Mar 15 11:02 README.md
drwxr-xr-x 6 k staff 192 Mar 15 11:02 app
-rw-r--r-- 1 k staff 73 Mar 15 11:02 jsconfig.json
-rw-r--r-- 1 k staff 92 Mar 15 11:02 next.config.mjs
drwxr-xr-x 10 k staff 320 Mar 15 11:02 node_modules
-rw-r--r-- 1 k staff 358 Mar 15 11:02 package.json
-rw-r--r-- 1 k staff 32753 Mar 15 11:02 pnpm-lock.yaml
-rw-r--r-- 1 k staff 61 Mar 15 11:02 postcss.config.cjs
drwxr-xr-x 4 k staff 128 Mar 15 11:02 public
-rw-r--r-- 1 k staff 469 Mar 15 11:02 tailwind.config.js
➜ aa git:(main) pnpm dev
> [email protected] dev /Users/k/p/aa
> next dev
▲ Next.js 14.2.0-canary.23
- Local: http://localhost:3000
✓ Ready in 2.4s
○ Compiling / ...
✓ Compiled / in 3.2s (523 modules) |
@karlhorky It would in the next stable patch release → |
Nice, thanks! Now that @phanect added ESM support in #63109, I have opened another PR with almost identical changes to switch to an ESM config with This makes the |
<!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change --> ### What? Now that @phanect added support for ESM PostCSS config files in PR #63109 (original issue #34448), PostCSS can use ESM config by default. It needs to use an `.mjs` extension by default because `create-next-app` scaffolds CommonJS apps by default. This will also work with ESM projects which have added `"type": "module"` in their `package.json` ### Why? 1. To convert one more file to ESM 2. To use the modern format 3. To follow other similar migrations that have taken place in the Next.js codebase (eg. `next.config.mjs`) ### How? - Change file extensions from `.cjs` to `.mjs` (change similar to PR #58380) - Change module format from CommonJS to ESM - Add type for the config, for users who enable `checkJs: true` in `tsconfig.json` Co-authored-by: Sam Ko <[email protected]>
What?
Prevent confusing error messages when changing to
"type": "module"
inpackage.json
Why?
Even though PostCSS itself supports ESM and TypeScript configuration files, Next.js itself does not (because of
next/lib/find-config
):next/lib/find-config
does not support ESM config files #34448How?
By switching to
.cjs
, the config will stay recognized as CommonJS even after switching to"type": "module"
inpackage.json
cc @balazsorban44