val-town / codemirror-ts

lint, hover, and autocomplete extensions for CodeMirror + TypeScript
https://val-town.github.io/codemirror-ts/
ISC License
105 stars 6 forks source link

Next.js build warnings #30

Closed huypham50 closed 1 day ago

huypham50 commented 6 days ago

Getting these warnings while yarn build Next.js application

$ next build
  ▲ Next.js 14.2.3
  - Environments: .env

   Creating an optimized production build ...
 ⚠ Compiled with warnings

./node_modules/@typescript/vfs/dist/vfs.esm.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/@typescript/vfs/dist/vfs.esm.js
./src/frontend/components/CodeEditor/typescriptExtensions.ts
./src/frontend/components/CodeEditor/editor.tsx
./src/frontend/components/CodeEditor/index.tsx

./src/frontend/components/CodeEditor/typescriptExtensions.ts
The generated code contains 'async/await' because this module is using "topLevelAwait".
However, your target environment does not appear to support 'async/await'.
As a result, the code may not run as expected or may cause runtime errors.

Import trace for requested module:
./src/frontend/components/CodeEditor/typescriptExtensions.ts
./src/frontend/components/CodeEditor/editor.tsx
./src/frontend/components/CodeEditor/index.tsx

./node_modules/typescript/lib/typescript.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/typescript/lib/typescript.js
./src/frontend/components/CodeEditor/typescriptExtensions.ts
./src/frontend/components/CodeEditor/editor.tsx
./src/frontend/components/CodeEditor/index.tsx

typescriptExtensions.ts is basically this demo on Stackblitz

Code editor still works, but I haven't been able to root cause these issues, have anyone seen anything similar?

tmcw commented 6 days ago

The error message around async/await is pretty descriptive: using an await statement on the top level is something that is not supported across all browsers, and your project is apparently configured to try and support browsers where top-level await isn't supported.

This is from the code in the example, which isn't part of the module proper. You can avoid the top-level await by using old-school .then() syntax on the createDefaultMapFromCDN call instead of awaiting it.

tmcw commented 1 day ago

Closing - these warnings are in application code rather than the module.