-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build impossible with rollup and typescript #59
Comments
Your repo can be compiled with --- a/package.json
+++ b/package.json
@@ -12,6 +12,6 @@
"typescript": "5.3.2"
},
"dependencies": {
- "picocolors": "^1.0.0"
+ "picocolors": "file:../picocolors"
}
} And built it and run it:
It works when using named exports as well: --- a/src/index.ts
+++ b/src/index.ts
@@ -1,9 +1,9 @@
-import pc from "picocolors";
+import { red } from "picocolors";
type Foo = {
a: string;
};
-const str: string = pc.red('Hello !');
+const str: string = red('Hello !');
console.log(str); And it still works when switching the project to ESM: --- a/package.json
+++ b/package.json
@@ -1,9 +1,10 @@
{
"name": "node-starter",
"version": "0.0.0",
+ "type": "module",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
- "build": "rollup -c rollup.config.js --bundleConfigAsCjs"
+ "build": "rollup -c rollup.config.js"
},
"devDependencies": {
"@rollup/plugin-typescript": "11.1.5",
@@ -12,6 +13,6 @@
"typescript": "5.3.2"
},
"dependencies": {
- "picocolors": "^1.0.0"
+ "picocolors": "file:.."
}
} --- a/rollup.config.js
+++ b/rollup.config.js
@@ -3,8 +3,7 @@ import typescript from '@rollup/plugin-typescript';
export default {
input: 'src/index.ts',
output: {
- dir: 'dist',
- format: 'cjs',
+ dir: 'dist'
},
external: ["picocolors"],
// switch the plugins option to make the build work |
Thanks a lot, that's very good ! |
@elturpin have you tried adding |
@alexeyraspopov |
Hi !
On a TS project using picocolors and rollup as builder, since the update of some packages (@rollup/plugin-typescript, and rollup) the project just cannot build when picocolors is imported. I found a fix where I add an
include
option to the ts plugin of rollup but the solution is not really satisfying.Here is a reproduction repository where I just kept the bare minimum : https://github.com/elturpin/test-rollup-ts-picocolors
I think that the problem come from some interaction with TS rollup plugin and picocolors because if I try with other packages (chalk, express ...) their is no problem. However i have completely no idea on why their is a problem ...
Maybe someone can solve this ?
The text was updated successfully, but these errors were encountered: