Commit graph

131 commits

Author SHA1 Message Date
Karl Horky
51b878f5a3
Switch to postcss.config.mjs, add type (#63380)
<!-- 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 <sam@vercel.com>
2024-03-18 16:57:55 +00:00
Karl Horky
dd536a51ec
Switch to .cjs PostCSS config (#58380)
<!-- 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?

### Why?

### How?

Closes NEXT-
Fixes #

-->


### What?

Prevent confusing error messages when changing to `"type": "module"` in
`package.json`

```
./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./src/styles/index.css
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/my/repo/components/postcss.config.js from /path/to/my/repo/components/node_modules/next/dist/lib/find-config.js not supported.
Instead change the require of postcss.config.js in /path/to/my/repo/components/node_modules/next/dist/lib/find-config.js to a dynamic import() which is available in all CommonJS modules.
```

### Why?

Even though PostCSS itself [supports ESM and TypeScript configuration
files](https://github.com/postcss/postcss-load-config/issues/230),
Next.js itself does not (because of `next/lib/find-config`):

- https://github.com/vercel/next.js/issues/34448

### How?

By switching to `.cjs`, the config will stay recognized as CommonJS even
after switching to `"type": "module"` in `package.json`

cc @balazsorban44

---------

Co-authored-by: Sam Ko <sam@vercel.com>
2024-03-11 14:19:50 -07:00
RightHot
fedcafaba7
Remove unnecessary 'await' from writeSema.release() call (#63117)
### What?
This PR removes an unnecessary await keyword from the
writeSema.release() call. The release method does not return a promise,
hence awaiting it is not required.

### Why?
Awaiting on writeSema.release() which does not return a promise can lead
to confusion and potentially hinder performance. By removing the await
keyword, the code is simplified and aligns with the intended synchronous
nature of the release method.

### How?
Reviewed the writeSema.release() method implementation to confirm it
does not return a promise.
Removed the await keyword from the writeSema.release() call to ensure
the code correctly reflects the synchronous operation.

Co-authored-by: righthot <righthot@everon.co.kr>
Co-authored-by: Steven <steven@ceriously.com>
2024-03-11 15:44:48 +00:00
Balázs Orbán
645be74efd
feat(cna): remove autoprefixer from default templates (#55725)
### What?

Removing `autoprefixer` from the default Tailwind CSS templates. (It can
be installed afterward)

### Why?

After some investigation by @timneutkens, `autoprefixer` seems to
introduce some compilation overhead

### How?

Removing `autoprefixer` from the auto-installed dependency list, it
would be up to the developer to install this plugin if they need it.

[Slack
thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1695288906722539)
2024-02-05 14:22:47 -05:00
Chris Weber
6efe76f954
CNA: exclude ts(js)conf.json as well as .git folder (#61412)
### What?

On windows the .git/* files are read only, when the CNA "import path" script attempts to open one of the .git/* files

### Why?

attempting to open any of the .git/* files results in an error thrown by CNA and CNA exists, hence not finishing the setup of a new project

### How?

My suggested fix uses the fast-glob ignore option to exclude the .git folder, I also moved the the ts(js)config.json exclusion into the ignore (was an "if" before)

- Fixes #61411 
- Discussion https://github.com/vercel/next.js/discussions/61261
2024-01-31 09:36:31 -05:00
Danny
c34b398b14
create-next-app: update tailwind packages and new classes in page.tsx (#61065)
- Updates `tailwindcss` package
- Fixes classes order based on `eslint-plugin-tailwindcss`
- Remove/updates certain classes that now have shorthands, for example
`lg:h-auto lg:w-auto` is now `lg:size-auto`
- Removes unnecessary curly braces

Co-authored-by: Sam Ko <sam@vercel.com>
2024-01-29 02:02:58 +00:00
Steven
4466ba436b
chore(examples): use default prettier for examples/templates (#60530)
## Description
This PR ensures that the default prettier config is used for examples
and templates.

This config is compatible with `prettier@3` as well (upgrading prettier
is bigger change that can be a future PR).

## Changes
- Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will
be needed upgrading to prettier@3)
- Added `examples/.prettierrc.json` with default config (this will
change every example)
- Added `packages/create-next-app/templates/.prettierrc.json` with
default config (this will change every template)

## Related

- Fixes #54402
- Closes #54409
2024-01-11 16:01:44 -07:00
Sukka
b8b104506d
refactor(cna): make create-next-app even smaller and faster (#58030)
The PR further reduces the `create-next-app` installation size by
another 80 KiB:

- Replace the callback version of Node.js built-in `dns` API usage with
`dns/promise` + async/await
- Replace `got` w/ `fetch` since Next.js and `create-next-app` now
target Node.js 18.17.0+
- Download and extract the tar.gz file in the memory (without creating
temporary files). This improves the performance.
- Some other minor refinements.

Following these changes, the size of `dist/index.js` is now 536 KiB.
2024-01-11 09:40:29 -05:00
Takashi Sato
e6e6609674
Remove unused target: es5 from tsconfig.json in create-next-app (#60521)
fixes #58640

When there is no tsconfig.json, `npm run dev` generates `tsconfig.json`,
which has no `target` option.
But create-next-app generates `tsconfig.json` with `"target": "es5"`

Related to: #44567
Related to: #14390
2024-01-11 14:35:17 +00:00
JJ Kasper
b16187213e
Use next.config.mjs for CNA templates (#60494)
As `.mjs` support for `next.config` is stable now we can swap our
default to use it instead.

Closes NEXT-2052
2024-01-10 14:04:57 -08:00
Hamir Mahal
f60c609bdb
style: enforce prop immutability in new next app (#58845)
- fixes #58844

Co-authored-by: Steven <steven@ceriously.com>
2024-01-05 09:55:27 -05:00
Hichem Fantar
5fde19b6d9
fix responsiveness in starter templates (#60140)
Fixes #60139
2024-01-04 14:28:10 +00:00
John Pham
d96a7e56a6
Add text-wrap: balance to CNA template for card descriptions (#59384)
### What?
This prevents the descriptions from having orphans at different viewport
widths.

### Why?

| Default | Pretty | Balance |
|--------|-------| --- |
|
![image](https://github.com/vercel/next.js/assets/16027268/66c8eac4-b995-4c30-9bdc-fd44a4a7fdda)
|
![image](https://github.com/vercel/next.js/assets/16027268/07a2e45a-728b-438f-a4e5-98f7c1c5c33a)
|
![image](https://github.com/vercel/next.js/assets/16027268/153fe94a-2b10-4e39-bb19-b1ca702bcea8)
|
2023-12-11 17:41:01 -08:00
Nhan Doan
adc636dd54
fix: update Next.js version in create-next-app (#57532)
### What?
The default template generated from `create-next-app` still says **Next.js 13**.

<img width="1053" alt="image" src="https://github.com/vercel/next.js/assets/2561973/1413dcda-d73d-43a9-ba47-8322cf193c52">

### Why?
Next.js 14 is released.
2023-10-31 01:36:27 +00:00
moka-ayumu
0623a4f79f
Modify tailwindcss related dependency of create-next-app (#57262)
### What?
If the version of `autoprefixer` is 10.0.0 and the version of `tailwindcss` is less than 3.3.0, the error `RangeError: Maximum call stack size exceeded` occurs when you create with tailwindcss & typescript and run it.

### Why?
The exact reason is unknown, but it appears to be a compatibility issue. Also, currently configuring tailwindcss with ts makes the tailwind config file in ts, which is supported since tailwindcss version 3.3.0. (In js, it works even if you set the version of `autoprefixer` to 10.0.1 and lower the version of tailwindcss.)

### How?
Simply default the minimum version of `autoprefixer` to 10.0.1 and the minimum version of `tailwindcss` to 3.3.0.
2023-10-30 17:54:28 +00:00
JJ Kasper
3010ae10e1
Update CNA tests to avoid publish conflict (#57025)
This avoids testing against latest exact canary version as this causes these tests to fail while the publish is still in progress. As a follow-up we can investigate moving this post publish or packing/deploying tarballs to use. 

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-10-19 13:52:10 +00:00
leung018
66597be8a7
Add .yarn/install-state.gz to .gitignore (#56637)
### Reason for making this change
https://yarnpkg.com/getting-started/qa#:~:text=yarn%2Finstall%2Dstate.,your%20workspaces%20all%20over%20again.
In the official documentation of `yarn`, it is stated that `.yarn/install-state.gz` is an optimization file that developer shouldn't ever have to commit. However, currently, when running `create-next-app`, `.yarn/install-state.gz` is being commited.

### Remaining work
I apologize for only modifying one template initially to initiate the discussion first.

If this change is agreed upon,  it should be synchronized with other `.gitignore` templates. Would it be possible to follow a similar approach as in https://github.com/vercel/next.js/pull/47241? I would appreciate any assistance in syncing this change.
2023-10-18 16:34:48 +00:00
Hamir Mahal
9288ef4921
feat: add self-documenting .env.example file (#56469)
- fixes #56468

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-10-12 21:55:14 +00:00
Hamir Mahal
187df91438
fix: .../templates/*/app/layout.* import order (#56380)
- fixes #56379
2023-10-04 20:41:47 +00:00
Balázs Orbán
4ec443931a
fix(cna): pin dependency versions (#56177)
### What?

This PR is pinning the installed versions of dependencies in `create-next-app`

### Why?

Currently, we write `latest` to `package.json`, 

### How?
As far as I can tell, there is no way to update the `package.json` file based on the lockfile (which does have the information needed).

Major versions are bumped less frequently, so this should be fine to update manually.

Other alternatives would be:
- return to the previous way of running `npm i --save` and `npm i --save-dev` instead (ref: #55730). This might be slightly slower than one `npm i` pass though.
- fetch the latest versions of each package from the registry. Might be even slower

NOTE: The user has always the alternative to update the versions to their desired ones afterward.

Fixes #56174
2023-09-28 18:22:02 +00:00
Balázs Orbán
bca6ff77f9
fix(cna): separate dependencies/devDependencies (#55730)
### What?

As [discussed](https://vercel.slack.com/archives/C04DUD7EB1B/p1692183798097169), we should follow the ecosystem standard separation of dependencies and dev dependencies.

### Why?

This is a common issue/misunderstanding that we always have to explain separately, while there is no real benefit.

One counter-argument was that install times would be increased when we had to run install for `dependencies` and `devDependencies` separately, but that's easy to work around as explained below.

### How?

Instead of passing the `dependencies` array to the package manager in the CLI, we write these to the `package.json` file and then run the package manager's install command without the dependency arguments.

This will also reduce the number of writes to the `package.json` file from two to just one.

Ref: https://github.com/vercel/next.js/pull/42218, https://github.com/vercel/next.js/pull/48076, https://github.com/vercel/next.js/issues/54105, https://github.com/vercel/next.js/pull/42012, and more

[Slack thread](https://vercel.slack.com/archives/C04DUD7EB1B/p1692183798097169)


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-09-21 15:30:37 +00:00
Jake Boone
3cd4b975c3
create-next-app templates: Change bun run dev commands to bun dev (#55603)
[As of Bun v1.0.0](https://bun.sh/blog/bun-v1.0#changelog-since-v0-8), `bun dev` runs the "dev" script from package.json. Therefore, as with Yarn and pnpm, the "run" command is not necessary.

This PR changes the `create-next-app` README templates to show `bun dev` instead of `bun run dev`.
2023-09-19 19:04:33 +00:00
YOSHIKI
7db5c64e94
docs: add bun run dev command to template readme for create-next-app (#55504)
## For Contributors

### Improving Documentation

- [x] Run `pnpm prettier-fix` to fix formatting issues before opening the PR.
- [x] Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide

### What?
add bun run dev command to template readme for create-next-app
2023-09-18 18:18:58 +00:00
stefanprobst
42227559c6
fix: don't add forceConsistentCasingInFileNames to tsconfig when ts version >= 5.0 (#51564)
Currently, Next.js enforces that `forceConsistentCasingInFileNames: true` is added to a user's `tsconfig.json`.

This PR removes that behavior for CNA templates, and when the typescript version is >= 5.0.0, because since ts 5.0 `forceConsistentCasingInFileNames` is `true` by default. See https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/

related: https://github.com/vercel/next.js/issues/45617
2023-08-15 19:12:40 +00:00
Julius Marminge
079813c11c
chore(create-next-app): use tailwind.config.ts for typescript templates (#47795)
Minor change to use `tailwind.config.ts` for TypeScript projects.
2023-08-01 20:05:57 +00:00
Sukka
127e30ed42
refactor(cna): make create-next-app even smaller (#53241)
The PR follows #53146 and #53115.

The PR does 3 things:

- Replaces a [very heavy dependency `cpy`](https://github.com/vercel/next.js/pull/53146#issuecomment-1649193789) with a more lightweight copy helper.
  - The `fs.cp(src, dest, {recursive: true})` API is not used, as it is still experimental:
  <img width="1630" alt="image" src="https://github.com/vercel/next.js/assets/40715044/c61a454a-3a96-4658-a389-fbb68c241f18">
- Update `cross-spawn` to the latest version `7.0.3`
  - The only breaking change introduced in `cross-spawn@7.x` is dropping Node.js 8 supports, which allows `cross-spawn` to drop a dependency. Since `create-next-app` requires Node.js 16.8.0, I assume bumping `cross-spawn` would be safe.
- Update `fast-glob` to the latest version `3.3.1` to remove more KiBs (pointed out by @imranbarbhuiya)
  - The breaking change introduced in `fast-glob@3.x` is dropping Node.js 8 supports and some options changes.

Together the PR removes another 202 KiB from the `create-next-app/dist/index.js`. The size of `create-next-app/dist/index.js` is now 616 KiB.

<img width="583" alt="image" src="https://github.com/vercel/next.js/assets/40715044/4deb5e36-a63b-4501-b67c-29ea06e30578">
2023-07-28 17:21:58 +00:00
Grace Yun
6c3560dbbd
[create-next-app] fix template css for top / bottom alignment (#53227)
Fixes a small CSS regression with the `create-next-app` template(s). Especially evident with templates using Tailwind CSS.

Before:
<img width="1047" alt="image" src="https://github.com/vercel/next.js/assets/74513600/9d3e8ef4-52b9-4590-be26-ee91f4bd65dd">

After:
![image](https://github.com/vercel/next.js/assets/74513600/952ca166-59df-40d1-bb6d-cb2fbc592c3b)
2023-07-26 20:41:08 +00:00
Sukka
66ffc3cd39
refactor(cna): replace chalk with picocolors, glob with fast-glob@2.2.7 (#53146)
Follows #53115

- Replace `chalk` with `picocolors`
  - Note that `chalk.hex('#007acc')` has been replaced with `picocolors.blue`
- Replace `glob` with `fast-glob@2.2.7`
  - Not only does `fast-glob` is a faster drop-in replacement of `glob` with first-party `Promise`-based API support, but also `fast-glob` is already a dependency of `cpy`:
 
  <img width="812" alt="image" src="https://github.com/vercel/next.js/assets/40715044/8efa24c4-5312-4b1c-bf8d-68255ca30b60">


Together the PR removes about `50 KiB` from the `create-next-app/dist/index.js`:

<img width="570" alt="image" src="https://github.com/vercel/next.js/assets/40715044/db2f3723-14cc-48ce-9cb2-8aa1fb1d5e95">


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-07-26 18:16:13 +00:00
Facundo Giuliani
a26bac9604
Update default moduleResolution in tsconfig.json from node to bundler (#51957)
This updates our `moduleResolution` to `bundler` as this matches our heuristics much more closely so is more accurate. This shouldn't be a breaking change is it should be compatible with our previous default. 

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2023-07-18 15:11:09 +00:00
Ryo Matsukawa
cf08f60077
fix(create-next-app): click event blockage under 1024px by adjusting z-index (#52074)
### What?

Fixed a bug that the title of the topmost Docs was unclickable when less than 1024px.

### Why?

This appears to be due to the fact that these clickable elements are overlapped by the logo image wrapper in Next.js, preventing the propagation of click events for these elements.

### How?

To mitigate this problem, this PR assigns a z-index of -1 to the Next.js logo image wrapper. This change ensures the wrapper is placed beneath the clickable elements, thereby preventing it from blocking click events on smaller screens.

#### Before

https://github.com/vercel/next.js/assets/76232929/7b84737d-8a43-4c92-870e-86d08e4eaf74

#### After

https://github.com/vercel/next.js/assets/76232929/648b2e9b-33b5-4905-b10f-03904c1f7529
2023-07-10 11:21:36 +00:00
Yiğithan
ce483fd7c3
fix(create-next-app): add missing metadata type (#52299)
This pull request adds the missing `Metadata` type declaration to the
root layout of the `create-next-app` templates. The metadata object was
missing its type definition, which has been resolved by adding the
appropriate type import and annotation.

---------
2023-07-06 09:58:43 -07:00
이현재
889e2203a5
Update page.tsx tw className (#49040)
I changed the tailwindcss code, which is written differently than the
other elements in `app/page.tsx`

<!-- 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 or adding/fixing 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?

### Why?

### How?

Closes NEXT-
Fixes #

-->

Co-authored-by: Shu Ding <g@shud.in>
2023-06-23 17:11:59 +02:00
조상현
2b5205a910
makeDir should use func (#50136)
Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2023-05-25 20:11:27 +00:00
Lee Robinson
fa1370fd9b
Update links from beta to stable docs. (#49349)
Now that the beta docs have been merged into stable with the release of
13.4, this updates all links as some paths have changed due to
redirects.

---------

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-11 11:52:29 -07:00
Tim Neutkens
25a9547cad
Remove experimental config from create-next-app (#49241)
## What?

Removes `experimental.appDir` this was leftover from when I flipped the
switch.

Kept the config file as in the future we might add future flags and
such. It also helps that it has the types comment included so you always
get types.

<!-- 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 or adding/fixing 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?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-05-05 00:22:28 -07:00
Balázs Orbán
b7d657f525
chore(cli): remove Route Handlers from App Router templates (#49076)
[Slack
thread](https://vercel.slack.com/archives/C04K237UHCP/p1682972426769409)

Closes NEXT-1077

---------

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2023-05-02 15:49:09 +02:00
Patrick Arminio
a40fa12c50
Remove unused font from tailwind app/page.tsx (#49035)
The font is imported and used in `app/layout.tsx` :)
2023-05-01 20:31:15 -07:00
Jesse Warren
a6afb3b9d8
Extra space removed (#48514)
Description: Extra space in /pages/index.js line 10 col 234 of
default-tw
2023-04-18 13:45:12 +00:00
JJ Kasper
9c5d0448ee
Update font handling in CNA templates (#48364)
We don't need to apply the font className to individual usage and can
just apply it to the the top element for easier usage.

x-ref: [slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1681343520829629)
2023-04-13 17:25:24 -07:00
Delba de Oliveira
ab213498d8
[create-next-app]: add mdx files to tailwind content config (#48188)
This PR updates create-next-app's tailwind config to consider .mdx files
when it generates styles.

If you're using MDX, most of a project's styles are generated by the
other file flags, which can make it tricky to debug/notice the rare
subset from .mdx only.

x-ref: https://vercel.slack.com/archives/C0290CZ3U6Q/p1680976472444189

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-04-13 16:39:36 -07:00
Karl Horky
3ad55721d1
Remove incorrect entries for pnpm debug log (#47241)
**Reasons for making this change:**

- it is contained within `node_modules/`, which is already ignored
- the previous versions, which were not in `node_modules/`, did not have
a period at the beginning of the filename

Links to documentation supporting these rule changes:

**Changelog with proof here:**


ba4b2db1f2/pnpm/CHANGELOG.md (L3330)

History:

- my PR to remove this from `github/gitignore` here:
https://github.com/github/gitignore/pull/4250
- First introduced in `github/gitignore` in
https://github.com/github/gitignore/pull/3732 by `@sakurayang` (merged
by `@martinwoodward`)

<!-- 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 or adding/fixing 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?

### Why?

### How?

Closes NEXT-
Fixes #

-->

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-26 22:26:05 -07:00
vinay
ac8741236a
fix(cli): change file name from route.ts to route.js (#47352)
<!-- 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 or adding/fixing 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?

### Why?

### How?

Closes NEXT-
Fixes #

-->
Wrong file for api endpoint `/hello` in create-next-app template for app
directory with tailwindcss.
The file was `route.ts` in javascript version of the template, changed
it to `route.js`.
2023-03-21 16:57:26 -07:00
shivanshubisht
cf66c2dc74
Replace bg-opacity with bg-color/opacity in tailwindcss templates (#47253)
In Tailwind v3, the bg-opacity has been deprecated in favour of
bg-color/opacity.
https://tailwindcss.com/docs/background-color#changing-the-opacity

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-20 16:33:12 -07:00
Balázs Orbán
2a8961b36b
fix(cli): unify styles/content of templates (#47294)
### What?

- fixes some typos
  - [x] getting started by editing "filename"
  - [x] match app/pages content
  - [x] fix utm params 
- [x] Reverted different text coloring in the CLI as they were hard to
read on a dark background
- [x] removes 13 ([Slack
thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1679151687968809?thread_ts=1679123593.519319&cid=C03KAR5DCKC))


### Why?

Unifying the styles across all templates

### How?

Used
https://github.com/vercel/next.js/tree/canary/packages/create-next-app/templates/default/js
as the base and made sure that all other templates match its content and
styling.

Related: #46927. This PR was extracted from #47238 to make reviewing
easier.

fix NEXT-851 ([link](https://linear.app/vercel/issue/NEXT-851))

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-20 15:33:44 -07:00
Balázs Orbán
5448c234d6
fix(cli): handle Tailwind CSS + src/ correctly (#47238)
### What?

- [x] fixes a bug in the CLI with the combination of `--tailwind` and
`--src-dir` flags.
- [x] fixes Tailwind CSS config when `--src-dir` is set
- [x] respect `NEXT_TEST_SKIP_CLEANUP` in test utils

### Why?

`pnpm create next-app@canary --tailwind --src-dir` should not fail.

### How?

We introduced the `app-tw` and `default-tw` templates, so we need to
respect them when working with files (in this case, the CLI was
erroneously assuming that if `template !== "app"` it must be a pages
template.)

I also noticed that the `tailwind.config.js` file need to also respect
`--src-dir` by prefixing the paths in `content`

Fixes #47236
fix NEXT-838 ([link](https://linear.app/vercel/issue/NEXT-838))

Related: #46927, #47276

---------

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2023-03-20 14:21:29 -07:00
Balázs Orbán
8c98a207f2
feat(cli): introduce --tailwind flag (#46927)
### What?

This PR introduces a new `--tailwind` flag to the `create-next-app` CLI,
to make it easier to bootstrap a Next.js app with Tailwind CSS
pre-configured. This is going to be the **default**. To opt-out of
Tailwind CSS, you can use the `--no-tailwind` flag.

### Why?

Tailwind CSS is one of the most popular styling solutions right now, and
we would like to make it easier to get started.

Currently, the closest you can come to this is by running `pnpm create
next-app -e with-tailwindcss` which will clone the
https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss
example. But that example is not configured for the App Router. This PR
will let you add Tailwind CSS to both `app/`, `pages/`, and start out
with TypeScript or JavaScript via the CLI prompts.

(Some community feedback
https://twitter.com/dev_jonaskaas/status/1632367991827443713,
https://twitter.com/samselikoff/status/1634662473331617794)

### How?

We are adding 4 new templates to the CLI bundle.

> Note: The styling is not pixel-perfect compared to the current
templates (using CSS modules) to require fewer overrides, but I tried to
match it as close as possible. Here are a few screenshots:

<details>
<summary><b>Current, light</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733372-9dba86fe-9191-471d-ad9f-ab904c47f544.png"/>
</details>

<details>
<summary><b>Tailwind (new), light</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733610-038d9d0f-634d-4b69-b5c2-a5056b56760c.png"/>
</details>

<details>
<summary><b>Current, dark, responsive</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224733790-9b4d730c-0336-4dbe-bc10-1cae1d7fd145.png"/>
</details>

<details>
<summary><b>Tailwind (new), dark, responsive</b></summary>
<img
src="https://user-images.githubusercontent.com/18369201/224734375-28384bbc-2c3a-4125-8f29-c102f3b7aa1d.png"/>
</details>

#### For reviewers

This introduces 4 new templates, with a very similar code base to the
original ones. To keep the PR focused, I decided to copy over duplicate
code, but we could potentially create a shared folder for files that are
the same across templates to somewhat reduce the CLI size. Not sure if
it's worth it, let me know. Probably fine for now, but something to
consider if we are adding more permutations in the future.

---

~Work remaining:~

- [x] app+ts
	- [x] layout
	- [x] dark mode
	- [x] media queries
	- [x] animations
- [x] app+js
- [x] pages+ts
- [x] pages+js
- [x] prompt/config
- [x] deprecate Tailwind CSS example in favor of CLI
- [x] update docs
- [x] add test
- [x] add [Prettier
plugin](https://github.com/tailwindlabs/prettier-plugin-tailwindcss)
 
Closes NEXT-772
Related #45814, #44286
2023-03-16 16:06:27 +01:00
Steamed_EGG
d08caa88ba
Fix: Update README templates in create-next-app (#47037)
To make them up to date with other templates

<!-- 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 or adding/fixing 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?



### How?

Closes NEXT-
Fixes #

-->
### Why?

I was using `create-next-app` to create my new app using the new `app`
directory but found out that `README.md` is outdated:
It shows informations for API Routes, which removed in #45819 in favor
of route handlers.

---------
2023-03-13 13:20:39 -07:00
teobler
b6b7933377
fix: generate next-env.d.ts file during next lint command (#46249)
fixes #46104

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)

---------

Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
2023-02-28 11:51:22 -08:00
Tom Ballinger
474b115e6d
Remove baseUrl from create-next-app ts/jsconfig.json (#46458)
Fixes #46288

Makes TypeScript behavior match runtime by no longer allowing files to
be imported absolutely relative to project root without using a relative
path or a path alias. This changes behavior introduced in
https://github.com/vercel/next.js/pull/44672 which also added the paths
alias `@/*: ["./*"]`, which works without a baseUrl.

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have a helpful link attached, see
[`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md)
2023-02-27 12:16:04 -08:00
Lee Robinson
4f0d76c40b
Migrate create-next-app and e2e tests to Metadata API. (#45819)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2023-02-23 23:40:06 +00:00