8000 v4: provide plugin.js in both mjs and cjs variants (Node 23) · Issue #8534 · activeadmin/activeadmin · GitHub
[go: up one dir, main page]

Skip to content
v4: provide plugin.js in both mjs and cjs variants (Node 23) #8534
Closed
@4ndv

Description

@4ndv

When trying to use AA v4 with vite_rails the fact that plugin.js is written in cjs, but package.json has "type": "module" causes issues with require inside of it

Expected behavior

Tailwind plugin should work correctly with vite_rails

Actual behavior

Errors like:

17:48:58 vite.1   | Error [ERR_REQUIRE_ESM]: require() of ES Module /redacted/node_modules/.pnpm/@activeadmin+activeadmin@4.0.0-beta13/node_modules/@activeadmin/activeadmin/plugin.js from /redacted/tailwind-active_admin.config.cjs not supported.
17:48:58 vite.1   | plugin.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.
17:48:58 vite.1   | Instead either rename plugin.js to end in .cjs, change the requiring code to use dynamic import() which is available in all CommonJS modules, or change "type": "module" to "type": "commonjs" in /redacted/node_modules/.pnpm/@activeadmin+activeadmin@4.0.0-beta13/node_modules/@activeadmin/activeadmin/package.json to treat all .js files as CommonJS (using .mjs for all ES modules instead).

How to reproduce

Try to require default AA tailwind config from postcss in vite_rails project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0