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

issues: When the content of the entry file is export * from "path/to/file", the output declaration file is empty #167

Closed
aaaaaajie opened this issue Aug 13, 2021 · 5 comments

Comments

@aaaaaajie
Copy link

aaaaaajie commented Aug 13, 2021

Example:
kernel/utils.ts

import _ from "lodash";

export function keyBy<T>(list: T[], iteratee?: (x: T) => void) {
    return _.keyBy(list, iteratee);
};

export function isNull(value: any): boolean {
    return _.isNull(value);
}
// other function

kernel/index.ts

export * as _ from "./utils";

dts-bundle.config.json

{
    "compilationOptions": {
        "followSymlinks": true,
        "preferredConfigPath": "./tsconfig.json"
    },
    "entries": [
        {
            "filePath": "./kernel/index.ts",
            "outFile": "./dist/kernel/index.d.ts"
        }
    ]
}

command dts-bundle-generator --config ./dts-bundle.config.json

Output file: ./dist/kernel/kernel.d.ts

export {};

This is my first time using this tool. I don't know if the method is wrong or the tool does not support this feature. I hope to get your help. Thanks a lot

@aaaaaajie
Copy link
Author

aaaaaajie commented Aug 13, 2021

Additional remarks:
tsconfig.json

{
  "compilerOptions": {
    "target": "es2017", 
    "module": "commonjs",
    "declaration": true,
    "declarationMap": true,
    "outDir": "./dist",
    "rootDir": "./",

    "strict": false,
    "noImplicitAny": false,
   
    "moduleResolution": "node",
    "baseUrl": ".",
    "paths": {
      "#kernel": [
        "./dist/kernel/#kernel.d.ts"
      ],
      "#src": [
        "./src/index.ts"
      ]
    },
    "rootDirs": [
      "."
    ],
   
    "types": [
      "node"
    ],
   
    "esModuleInterop": true, 
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true
  }
}

@timocov
Copy link
Owner

timocov commented Aug 13, 2021

@aaaaaajie can you create a repro for that please? (so I can run dts-bundle-generator locally without guessing package versions, source files code, etc)

@aaaaaajie
Copy link
Author

aaaaaajie commented Aug 16, 2021

@aaaaaajie can you create a repro for that please? (so I can run dts-bundle-generator locally without guessing package versions, source files code, etc)

Sorry,I provided a repro: https://github.com/aaaaaajie/dts-bundle-generator-demo 😋

@aaaaaajie
Copy link
Author

aaaaaajie commented Aug 16, 2021

I think you must have known dt-bundle,The following code can achieve my needs,dts-bundle has not been updated 3 years ago, so I dare not use it boldly

const dtsBundle = require("dts-bundle");
const path = require("path");
dtsBundle.bundle({
    name: "#kernel",
    main: path.join(__dirname, "../dts-build/server/kernel/", "index.d.ts"),
    out: path.join(__dirname, "../dist", "kernel.d.ts")
});

@timocov
Copy link
Owner

timocov commented Aug 17, 2021

@aaaaaajie thanks!

As I can see, you use export default in your files and then export them as export * from, which might not work (as I tested), I meant you cannot import these exports after that.

As for export * as name thing - please see #134.

@timocov timocov closed this as completed Sep 22, 2021
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

2 participants