question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Doesn't follow `package.json` `type` in `rollup.config.ts` code?

See original GitHub issue

Troubleshooting

link: https://stackoverflow.com/questions/73554514/when-using-rollup-config-ts-how-to-deal-with-dependencies-that-only-contain-es

I’m building with rollup --config rollup.config.ts --configPlugin typescript2 and when encountering a plugin containing only ESM exports during construction then, Rollup throws a ERR_REQUIRE_ESM exception.

At present, many packages have changed to support only ESM. Can rollup-plugin-typescript2 automatically convert to MJS or CJS based on "type": "module" field?

added by agilgur5 from the SO link:

// plugin
import { Plugin } from 'rollup'
import boxen from 'boxen' // this is a only contain esm package

export const totalSize = (): Plugin => {
    const plugin: Plugin = {
        name: 'rollup-plugin-total-size',
        buildEnd() {
            boxen(` point info `)
        }
    }
    return plugin
}
// rollup.config.ts
import { totalSize } from './plugin'

export default () => {
    input: 'lib/index.ts',
    output: 'dist/index.js',
    plugins: [
      // total bundle size
      totalSize()
    ]
}

Environment

any where

Versions

"rollup": "^2.70.2",
"rollup-plugin-typescript2": "^0.31.2",

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
halo951commented, Sep 6, 2022

look here: https://stackblitz.com/edit/rpt2-repro-ccfqkv?file=plugins/rollup-test-plugin.ts

please run build and see rollup-test-plugin

0reactions
agilgur5commented, Sep 6, 2022

look here: https://stackblitz.com/edit/rpt2-repro-ccfqkv?file=plugins/rollup-test-plugin.ts

please run build and see rollup-test-plugin

npm run build works once you fix the package.json (you have an additional comma there).

So this doesn’t quite show the error either 😕

Read more comments on GitHub >

github_iconTop Results From Across the Web

type-checking doesn't work on type-only modules #298 - GitHub
What happens and why it is wrong When module contains only types (type,interface), and those types are being imported in other module, ...
Read more >
rollup.js
js. Rollup allows you to write your code using the new module system, and will then compile it back down to existing supported...
Read more >
Does rollup support typescript in rollup config file?
With Rollup v2.52.0, you can specify a --configPlugin option as: rollup --config rollup.config.ts --configPlugin typescript.
Read more >
Introduction - rollup.js
Introduction. Overview. Rollup is a module bundler for JavaScript which compiles small pieces of code into something larger and more complex, ...
Read more >
rollup-plugin-typescript2 - npm package - Snyk
Seamless integration between Rollup and TypeScript. Now with errors. For more information about how to use this package see README.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found