Skip to content
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

Typescript Generated an empty chunk #756

Closed
AndyOGo opened this issue Nov 22, 2020 · 3 comments
Closed

Typescript Generated an empty chunk #756

AndyOGo opened this issue Nov 22, 2020 · 3 comments

Comments

@AndyOGo
Copy link

AndyOGo commented Nov 22, 2020

I'm migrating one of my projects to typescript and suddenly my build yields empty chunks.
rollup emits this warning here:
https://github.com/rollup/rollup/blob/95400517f8bba1146d23654a881616f280db0346/src/Chunk.ts#L642-L649

This is my PR: https://github.com/AndyOGo/stylelint-declaration-strict-value/pull/119/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519

> microbundle --tsconfig tsconfig.json -i src/index.ts

Generated an empty chunk: "index"
Generated an empty chunk: "index"
Generated an empty chunk: "index"
Generated an empty chunk: "index"
Build "stylelintDeclarationStrictValue" to dist:
         21 B: index.js.gz
          5 B: index.js.br
         21 B: index.esm.js.gz
          5 B: index.esm.js.br
         21 B: index.modern.js.gz
          5 B: index.modern.js.br
         64 B: index.umd.js.gz
         53 B: index.umd.js.br
@AndyOGo AndyOGo closed this as completed Nov 22, 2020
@Hotell
Copy link

Hotell commented Mar 23, 2021

How was this resolved? I'm getting same warning.

Repro:

// @file tsconfig.json
{
  "compilerOptions": {
    "declaration": true,                    
    "declarationMap": true,        
    "declarationDir": "./dist/types",
    "emitDeclarationOnly": true,
  }
}

Workaround:

if type declarations are created only via microbundle (rollup ts plugin), there are no warnings.
Looks like ts rollup plugin has some issues with emitDeclarationOnly flag.

// @file tsconfig.json
{
  "compilerOptions": {
-    "declaration": true,                    
-    "declarationMap": true,        
-    "declarationDir": "./dist/types",
-    "emitDeclarationOnly": true,
+   "noEmit": true
  }
}

@Hotell
Copy link

Hotell commented Mar 23, 2021

Update:

so if emitDeclarationOnly is explicitly set in tsconfig.json it will be propagated to typescript rollup plugin, thus the output is as expected === .d.ts files only are generated, thus there is no runtime code to rollup!

Initially I thought that babel is used for transpilation no matter what ( which from my experience, would be definitely preferred as TS has various shortcomings when doing actual transpilation)

@agilgur5
Copy link
Contributor

For reference, the issue here was upstream in rpt2 ezolenko/rollup-plugin-typescript2#268, where rpt2 previously did not have any special handling of emitDeclarationOnly. The TS compiler would give back empty and that would be passed back to Rollup.

I recently added support for emitDeclarationOnly in rpt2 in ezolenko/rollup-plugin-typescript2#366, which was recently released in rpt2 0.33.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants