deno icon indicating copy to clipboard operation
deno copied to clipboard

fix: add suggestion how to fix importing CJS module

Open bartlomieju opened this issue 1 year ago • 2 comments
trafficstars

Screenshot 2024-01-02 at 22 16 22

Similar mechanism can be used to fix https://github.com/denoland/deno/issues/21712

bartlomieju avatar Jan 02 '24 21:01 bartlomieju

Really like the idea of providing suggestions.

Here's a little more real-worldy next config: https://github.com/timlrx/tailwind-nextjs-starter-blog/blob/main/next.config.js

Ideally Deno could provide suggestions for migration:

| const { withContentlayer } = require('next-contentlayer')
                               ^^^^^^^
Deno doesn't support CommonJS in user code, that is, outside of npm modules.

hint: use `import { withContentLayer } from "next-contentlayer"`;

| const withBundleAnalyzer = require('@next/bundle-analyzer')({
                             ^^^^^^^

Deno doesn't support CommonJS in user code, that is, outside of npm modules.

hint: use:
          import $ from "@next/bundle-analyzer";
          const withBundleAnalyzer = $({
            enabled: process.env.ANALYZE === 'true',
          });

littledivy avatar Jan 03 '24 15:01 littledivy

Ideally Deno could provide suggestions for migration:

being able to have a CLI option to autofix given hint would really be helpful.

scarf005 avatar Jan 10 '24 00:01 scarf005

Update the error message and land, but first do https://github.com/denoland/deno/issues/25384

bartlomieju avatar Sep 03 '24 10:09 bartlomieju