Is it advisable to include JavaScript files produced by TypeScript in the gitignore when creating a library?

As I develop my library, my TypeScript files reside in the src directory. To streamline the process, I have set up the tsc compiler to generate JavaScript files in a separate js folder, with the final bundled scripts stored in a dist folder.

Considering that the js and dist folders are essentially derivatives of the TypeScript source code in src, it may not be necessary to include them in the git repository. By excluding these folders in the .gitignore file and including them in .npmignore, they will still be part of the npm release package.

Before each release, I conduct tests using the files from the js folder. Passing these tests ensures that both js and dist directories are properly prepared for publication on npm.

One drawback of this approach is that cloning the repository would not provide access to the compiled files directly; users would need to run npm install and build the files themselves. However, avoiding bloated commits by omitting pre-compiled files could outweigh this inconvenience.

Is it considered poor practice to exclude js and dist folders from version control in git?

Answer №1

Is it recommended to exclude JavaScript files generated by TypeScript from gitignore?

Absolutely. It's best to ignore them.

Explanation

The JavaScript files are already present as a build artifact, and it's typical to exclude build artifacts from version control. Following this practice is common among developers working with TypeScript.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Unveiling the secrets of manual mocking with chained methods in Jest

Looking to manually mock the npm module unirest with jest, I've created an __mocks__ folder and placed unirest.js inside. Despite creating post and headers methods, I'm encountering this error. How can I properly set up these chained methods to r ...

Set the value of HTML input type radio to a nested JSON string

Currently, I'm developing an Angular application and encountering an issue where I am unable to access the nested array value 'subOption.name' for the input type radio's value. I'm uncertain if the error lies within the metaData st ...

Issue with the `instanceof` operator not functioning properly when used with Immutable.js

We've encountered an issue while upgrading our project from typescript2.4 to typescript3.2 specifically with immutable.js. Prior to the update, simply using if(x instanceof Immutable.Iterable) would result in the type of x being Immutable.Iterable< ...

React Error: Unable to access property 'getBoundingClientRect' because it is undefined

server: Node.js, MongoDB, Graphql front-end: React --typescript, apollo-client, Graphql I believe the issue lies in the timing or sequencing of data retrieval and rendering. However, I'm struggling to find a solution to this problem. Error Uncaug ...

Is it possible for me to create a union type that connects parameters and responses in a cohesive manner

I'm interested in creating a custom type that functions can use to indicate to callers that an input parameter of a specific type corresponds to a certain output type. For instance, consider the following scenario: type ResponseMap = { requestPath: ...

How to create a boolean observable that emits hot values with switchMap?

Looking to develop a method named isEmpty:Observable<boolean> that generates a hot Observable<boolean> by employing a switchMap. Here's what I have so far: /** * Notifies observers when the store is empty. */ protected notifyOnE ...

axios.get consistently delivers a Promise of type <Pending>

I have been searching for a solution to my issue, but so far none of the suggestions have worked for me. Below is the code that I am struggling with: const Element = () => { async function getEndData() { const data = (await getEnd()) ...

Error: Axios header not refreshing automatically in React. User must manually refresh the page

After logging in, I want to update the JWT token in the header before redirecting to the home page. Login.tsx ... const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => { event.preventDefault(); const data = new FormData(event.curr ...

Configuring Firebase Functions: Setting Up an Optimal Geographical Region

After running a firebase deploy command for a Firebase Function, I noticed that it defaults to ✔ functions[helloWorld(us-central1)]: Successful create operation. I'm wondering where I should specify the region for the function. Below is the code ...

A step-by-step guide on how to view and remove all installed npm packages from your

How can I view and remove all of my installed npm packages (such as nodemailer, json, etc) and clear npm's history? I've come across the suggestion to use npm list -g to see all packages, but after recently downloading nodemailer, it doesn' ...

Receiving data from multiple sockets in Node.js with Socket.io

I recently started working with Node.js to develop an online game that acts as a server-side application. This application serves the .html and .js files to the client while managing the game's logic. I'm utilizing Socket.io for communication bet ...

Is it necessary to package files before releasing a library on npm?

Here's a rough overview of my project structure: dist/ - helper.compiled.js - entrypoint.compiled.js src/ - helper.js - entrypoint.js As I was going through the npm publishing guidelines, I noticed they recommend providing a single index.js fi ...

Creating a new endpoint within the Angular2 framework using typescript

I am brand new to Angular2 and I would like to streamline my API endpoints by creating a single class that can be injected into all of my services. What is the most optimal approach for achieving this in Angular2? Should I define an @Injectable class sim ...

leveraging services in Angular 4's router system

Below is the route setup: export const routes: Routes = [ {path: '', redirectTo: '/login', pathMatch: 'full'}, {path: 'login', component: LoginComponent, canActivate: [dbs.ConfigGuard]}, {path: '**& ...

Exploring the functionality of the Angular 7 date pipe in a more dynamic approach by incorporating it within a template literal using backticks, specifically

I have a value called changes.lastUpdatedTime.currentValue which is set to 1540460704884. I am looking to format this value using a pipe for date formatting. For example, I want to achieve something like this: {{lastUpdatedTime | date:'short'}} ...

What is the method to group a TypeScript array based on a key from an object within the array?

I am dealing with an array called products that requires grouping based on the Product._shop_id. export class Product { _id: string; _shop_id: string; } export class Variant { variant_id: string; } export interface ShoppingCart { Variant: ...

Determining when to include @types/packagename in React Native's dev dependencies for a specific package

Just getting started with React Native using typescript. Take the package vector icon for example, we need to include 2 dependencies: 1. "react-native-vector-icons": "^7.1.0" (as a dependency) 2. "@types/react-native-vector-icons": "^6.4.6" (as a dev ...

Encountered a problem while trying to install npx expo-cli due to the issue: getaddrinfo EN

While trying to kick off a new react native project using npx expo-cli init within a proxy network, I encountered the following error message: Encountered an issue while attempting to download and extract the template. request to https://registry.npmjs.org ...

Invalid characters have been found in literals within the transpiled JavaScript output

In my TypeScript code, I have a field definition that is structured like this: languages: Array<{}> = [{ key: "fr", name: "français" }]; However, when the TypeScript file is compiled into JavaScript, the output ends up looking like this: this.lan ...

Is there a yarn equivalent for perpetually running nodes?

Currently, I run the command yarn run dev-server using the screen. I am searching for an alternative method similar to: forever start app.js Specifically for the yarn run dev-server command. The definition of dev-server in package.json is equal to "dev- ...