vercel / vercel/next.js

Including exclamation mark(" ! ") in assetPrefix compilation will result in an error

Open
#71,426 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug create-next-app
Dominant language
JavaScript
Stars
142k
Forks
32.4k
Avg merge
2d 14h
Merged PRs (30d)
351

Description

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/xenodochial-easley-ddh8vq?workspaceId=6bdce0be-af7a-405b-adec-ac633e9ed70d

To Reproduce

Add the following config to "next.config.mjs":

output: "export",
assetPrefix: "https://mycdn.com/!mark",

if the assetPrefix incude "!" will trigger error
if change the "!" to "21%" will be ok (but not my need)

Current vs. Expected behavior

Current:

➜  workspace git:(master) ✗ yarn build
yarn run v1.22.19
$ next build
  ▲ Next.js 15.0.0-canary.196

   Creating an optimized production build ...
Failed to compile.

Module not found: Error: Can't resolve 'mark&nextConfigOutput=export&flyingShuttle=false&nextConfigExperimentalUseEarlyImport=&preferredRegion=&middlewareConfig=e30%3D' in '/project/workspace'

Module not found: Error: Can't resolve 'mark&nextConfigOutput=export&flyingShuttle=false&nextConfigExperimentalUseEarlyImport=&preferredRegion=&middlewareConfig=e30%3D' in '/project/workspace'

Module not found: Error: Can't resolve 'mark&nextConfigOutput=export&flyingShuttle=false&nextConfigExperimentalUseEarlyImport=&preferredRegion=&middlewareConfig=e30%3D' in '/project/workspace'


> Build failed because of webpack errors
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Provide environment information
Operating System:
  Platform: linux
  Arch: x64
  Version: #1 SMP PREEMPT_DYNAMIC Sun Aug  6 20:05:33 UTC 2023
  Available memory (MB): 4102
  Available CPU cores: 2
Binaries:
  Node: 20.9.0
  npm: 9.8.1
  Yarn: 1.22.19
  pnpm: 8.10.2
Relevant Packages:
  next: 15.0.0-canary.196 // Latest available version is detected (15.0.0-canary.196).
  eslint-config-next: N/A
  react: 19.0.0-rc-77b637d6-20241016
  react-dom: 19.0.0-rc-77b637d6-20241016
  typescript: 5.3.3
Next.js Config:
  output: export
Which area(s) are affected? (Select all that apply)

create-next-app

Which stage(s) are affected? (Select all that apply)

next build (local)

Additional context

Both 15.0 and 14.x is not ok

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the assetPrefix in next.config.mjs and run next build using the linked CodeSandbox setup. Compare it with the working percent-encoded value, then trace how the assetPrefix is handled during the build; done means an exclamation mark no longer produces the reported module-resolution error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nextjs
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.