question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Excluding files from the build

See original GitHub issue

Hello

How can we exclude files from compilation (for example test files ending with .spec.ts)? I tried https://github.com/egoist/tsup/issues/415 but it errored:

ESM Build failed
Error: Build failed with 1 error:
error: The entry point "./src/api.spec.ts" cannot be marked as external

Then I switched from using npx tsup src to npx tsup src/index.ts and I got an error that other files are imported but are not entrypoints.

src/index.ts(1,15): error TS6307: File '<redacted>/src/endpoints.ts' is not listed within the file list of project ''. Projects must list all files or use an 'include' pattern.
  The file is in the program because:
    Imported via './endpoints' from file '<redacted>/src/index.ts'
    Imported via './endpoints' from file '<redacted>/api.ts'
src/index.ts(3,15): error TS6307: File '<redacted>/src/api.ts' is not listed within the file list of project ''. Projects must list all files or use an 'include' pattern.

Then I tried to “include” everything under “./src” in tsconfig.json, but it didn’t help.

Then I tried to use the glob library to exactly specify my import files and exclude test files, but I don’t think tsup supports asynchronous configs?

Is there a way to exclude files within the src directory (preferably without creating a node script that calls tsup’s “build” directly)?

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
echocrowcommented, Oct 3, 2022

@tenshouuu

ran into the same issue, and resolved it with a negative pattern, e.g.:

export default defineConfig({
  entry: ['src', '!src/**/*.spec.*'],
  // ...
})

(looks like tsup is using globby under the hood, thus its pattern features seem to work for the entry config option)

0reactions
tenshouuucommented, Sep 3, 2022

tsupConfig.external doesn’t work for this case

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to exclude files from Visual Studio compile?
Right click the file, select 'Exclude From Project' · Right click the file, select 'Properties' --> select 'Configuration Properties' --> select ...
Read more >
How to: Exclude Files from the Build - MSBuild | Microsoft Learn
Use conditions to exclude a file or directory from the inputs for a build ... If there are items that you want to...
Read more >
Exclude from Build - Visual Studio Marketplace
Select directories and/or files you'd like to exclude or include · Right-click the selection or go to menu Tools · Choose Exclude from...
Read more >
Excluding a folder from build. : r/VisualStudio - Reddit
How do I exclude a folder from being built for a while? I don't want to exclude it from the project as I...
Read more >
Excluding files or folders from builds - IBM Streams
To exclude files or folders when building a SPL application or toolkit, create a .buildignore file in the root of your SPL application...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found