Closed qingtiantongxie closed 2 years ago
Don't you need a separate plugin for using css with rollup? There is rollup-plugin-postcss
for example (never used it, so can't tell you much more than that)
Don't you need a separate plugin for using css with rollup? There is
rollup-plugin-postcss
for example (never used it, so can't tell you much more than that)
They're using rollup-plugin-styles
Per https://github.com/ezolenko/rollup-plugin-typescript2/issues/43#issuecomment-345007814 where this was linked to from, TS doesn't normally support CommonJS (and hence the require
syntax), and rpt2 does not support the legacy module: "CommonJS"
.
but when i change the file extension with .js , it's totally ok and run well in chrome
TS won't read it in that case unless you have allowJs: true
in your tsconfig
, but you didn't attach it here and removed much of the issue template.
In this case I believe you can just move rollup-plugin-commonjs
to come before rpt2 in your plugin order.
Similar to #43, you can also switch to using all import
statements instead, which are valid TS. This is more or less a duplicate of that issue.
This gets out-of-scope of this plugin, but you might run into more complications from there, as a dynamic require
(or dynamic import
) is often not statically analyzable, so Rollup may be unable to figure out what files to bundle, tree-shake, etc with it. rollup-plugin-copy
is often used to manually get around that if is truly required. Again, out-of-scope for here in any case. See https://stackoverflow.com/q/59063576/3431180 for more details.
I'm getting an error in chrome when i test my project in chrome, it's like this :
and I'm pretty sure it's not related to rollup-plugin-commonjs
some code
i meet the error when i use require statement in a .ts file like this
but when i change the file extension with .js , it's totally ok and run well in chrome
This is my rollup.config.js
Versions
do i missed sth or write sth wrong ?
:)