Skip to content

Next.js 15 and experimental import attributes #21

Description

@arnemolland

The generated files from contentlayer(2) makes use of the experimental import attributes feature when running Node > 16 which worked fine using Babel plugins with previous Next.js versions.

With Next.js 15, Babel has been replaced by swc which does not have any documented way to enable the experimental syntax. Next throws and suggests installing the Babel plugin, which didn't work for me at least (I use Turbopack). The quick fix for me was to patch the @contentlayer2/core package to remove the assert statement.

Removing the statement outright probably breaks stuff, providing a config option to disable them would be a quick fix but I'm not sure if it's the best way to do it either.

Note: The proposed syntax differs from the contentlayer(2) implementation and this will probably need to be updated in the near future anyway; the proposed keyword is with instead of assert.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions