Doesn't follow `package.json` `type` in `rollup.config.ts` code?
See original GitHub issueTroubleshooting
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:
- Created a year ago
- Comments:5
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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 thepackage.json
(you have an additional comma there).So this doesn’t quite show the error either 😕