Skip to content

Conversation

@pleb
Copy link
Contributor

@pleb pleb commented Feb 27, 2025

Note

The build is failing due to vulns being found in the audit step. PR #157 addresses this.

Main

The output configuration using Rollup is

  output: [
    {
      dir: 'dist',
      format: 'cjs',
      entryFileNames: '[name].js',
      preserveModules: true,
      sourcemap: true,
      dynamicImportInCjs: false,
    },
    {
      dir: 'dist',
      format: 'es',
      entryFileNames: '[name].mjs',
      preserveModules: true,
      sourcemap: true,
    },
  ],

As you can see, ESM gets the mjs extension. However, CJS keeps the traditional js extension.

However, in the package file

  "type": "module",
  "module": "index.mjs",
  "types": "index.d.ts",
  "main": "index.cjs",

you will notice the main import is referencing the cjs extension.

The output configuration using Rollup is

```ts
  output: [
    {
      dir: 'dist',
      format: 'cjs',
      entryFileNames: '[name].js',
      preserveModules: true,
      sourcemap: true,
      dynamicImportInCjs: false,
    },
    {
      dir: 'dist',
      format: 'es',
      entryFileNames: '[name].mjs',
      preserveModules: true,
      sourcemap: true,
    },
  ],
```

As you can see, ESM gets the `js` extension. However, CJS keeps the traditional `js` extension.
@pleb pleb force-pushed the fix-package-cjs-ref branch from da3b21d to 925f011 Compare February 28, 2025 01:14
@pleb pleb enabled auto-merge February 28, 2025 01:14
@pleb pleb merged commit faff3c2 into main Feb 28, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants