Do we really need TypeScript project references when transpiling with Babel in an Electron project using Webpack?

Currently, I am in the process of setting up my project configuration and have not encountered any errors so far. However, based on my understanding of the Typescript documentation...

It appears that Project references are not essential when using babel-loader to transpile in webpack while working with TypeScript (specifically in VSCode).

I am in the midst of transitioning an Electron application to TypeScript and reorganizing the folder structure to minimize potential issues. I am exploring whether omitting "references" and utilizing "extends" would suffice to achieve the desired functionality.🤔

Here is the simplified version of my project structure focusing only on the tsconfig files:


        ./tsconfig.json
        ./tsconfig-base.json
        ./main/tsconfig.json
        ./src/client/tsconfig.json
        ./__tests__
        ./__tests__/__client__/tsconfig.json
        ./__tests__/__main__/tsconfig.json
    

In this layout, ./tsconfig.json mainly serves as a reference similar to the example on Microsoft's Github.

The Electron Main Process and its associated files reside in ./main. The tsconfig file here sets "module":"commonjs" for compatibility with node. It also extends from ./tsconfig-base.json.

The Electron Renderer Process along with React-Redux app files are located in ./src/client. The tsconfig file here specifies "module":"es2015" or "module":"ESNEXT" for working with ES modules. This config also extends from ./tsconfig-base.json.

The test configurations -

./__tests__/__client__/tsconfig.json
and
./__tests__/__main__/tsconfig.json
are duplicates of their non-test folder counterparts, extending from the base configuration in ./.

The Webpack setup is already configured to handle bundling main and renderer processes separately, enabling the entire application to utilize TypeScript. Given this setup, is there a compelling reason to incorporate "references" in the main or client folders?

Below are excerpts of the Webpack configuration before converting the tnry files to .ts extension (for development):


        const rendererInclude = path.resolve(__dirname, "src");
        const mainInclude = path.resolve(__dirname, "main");
    

Main Process:


        module.exports = [
          {
            mode: "development",
            entry: path.join(__dirname, "main", "swell.js"),
            output: {
              path: path.join(__dirname, "dist"),
              filename: "main-bundle.js",
            },
            target: "electron-main",
            node: {
              __dirname: false,
              __filename: false,
            },
            resolve: {
              extensions: [".ts", ".tsx", ".js", ".json"],
            },
            module: {
              rules: [
                {
                  test: /\.(ts|js)x?$/,
                  loader: "babel-loader",
                  include: mainInclude,
                  exclude: /node_modules/,
                }
            ] } ... },
    

Continued to Renderer Process:


        {
            mode: "development",
            entry: path.join(__dirname, "src", "index.js"),
            output: {
              path: path.join(__dirname, "dist"),
              filename: "renderer-bundle.js",
            },
            target: "electron-renderer",
            resolve: {
              extensions: [".ts", ".tsx", ".js", ".json"],
            },
            module: {
              rules: [
                {
                  test: /\.(ts|js)x?$/,
                  loader: "babel-loader",
                  include: rendererInclude,
                  exclude: /node_modules/,
                ]} ...} ]
    

Answer â„–1

Enhance Your Projects offers a solution to the challenges that arise when your test projects import src/main modules. Here's how Enhance Your Projects can help:

  • No need for manual up-to-date checking, eliminating redundant tsc runs
  • Avoiding unnecessary double tsc invocation saves on startup time
  • tsc -w is not limited to one config file at a time

Learn more about Enhance Your Projects

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

Shortcuts for $scope variables in AngularJS templates

Within my controller, I often set: $scope.currentThing.data For different parts of my template, sometimes I require currentThing.data.response[0].hello and other times currentThing.data.otherStuff[0].goodbye //or currentThing.data.anotherThing[0].goo ...

Issue with IE7 Dropdownlist not appearing after changing class name when onFocus event is triggered for the first time

I need to adjust the CSS class of a dropdownlist when it is focused on, in order to change its background color. However, in IE7, when the dropdownlist is clicked, the CSS class changes but the options list does not appear until the dropdownlist is clicke ...

The CosmosClient's read() method will only return an object if both the ID and partition key value are provided

After setting up a CosmosDB instance and inserting a test object into the container products, with the partition key set to /price, I encountered an issue. The item added had the following properties: { "id": "1234", "name": "A DB product", "p ...

Encountering the error `RollupError: Expression expected` during the compilation of an NPM package

Following the setup of my environment to create my initial NPM package for React JS with ROLLUP bundler, I encountered a RollupError: Expression expected error message as displayed below: Error Message > rollup -c --environment NODE_ENV:development dev ...

WebGL annotations failing to display on the webpage

I'm currently working on displaying a 3D model using Three.js in a web browser and looking to incorporate annotations like the ones shown in this Sketchfab model: Interactive 3D Test. I came across a helpful guide at this link, but I'm facing iss ...

Is there a way to automatically remove files from the "dist" directory when deleting the prototype from the "src" folder?

I am new to build systems and seeking assistance with the following question. Here is the structure of my boilerplate: /src (working folder) ___/templates(jade files) ___/scss ___/scripts /dist (compiled files) ___/css ___/js ___.html files In the te ...

Transition from traditional class-based components to functional components

I am utilizing the ref from the parent class to access the child class. However, in this scenario, I want to access the child functional component from the parent class. In the parent class: class Waveform extends Component { constructor(props){ s ...

I'm having trouble getting the aggregation of a child collection to work properly in MongoDB when attempting to apply the $count

Could someone help me troubleshoot my aggregate query? I'm trying to sum the count values for each beacon, but it keeps returning 0. Please let me know if you spot any mistakes in the query. Sample Data [ { ...

What is the best method for extracting information from different websites? I typically utilize the $.post function for this task

Currently conducting a test on a javascript code located on localhost. The script is dependent on receiving data in JSON format from a remote server. Strangely, when I manually access the JSON url, the data loads without issue. However, when using JavaScri ...

Fetching dynamic JavaScript generated by PHP

I am creating a lightweight website and I have a piece of javascript code that I want to convert into a module by putting it in a separate file. This way, the code will only be loaded after a specific onClick event occurs. Successfully loading the javascr ...

How to Utilize Knockout's BindingHandler to Integrate JQuery.Datatables Select Feature?

I've developed a custom KO bindingHandler (view it here) to assist in updating the DataTable. The documentation for JQuery.DataTable.Select regarding how to access data requires a handle. You can see the details here. var table = $('#myTable&a ...

`How can I effectively integrate react-i18next with the Semantic UI label element?`

Currently, I am working with Semantic UI along with the integration of [react-i18next][2]. My goal is to enable translation for label strings, but these labels include HTML tags, such as span. Unfortunately, the system only allows hardcoded or variable s ...

Design a TypeScript interface inspired by a set static array

I am working with an array of predefined strings and I need to create an interface based on them. To illustrate, here is an example of pseudo-interfaces: const options = ["option1", "option2", "option3"]; interface Selection { choice: keyof options; ...

Align the image in the middle using JavaScript for Firebase

I am struggling to display the center of an image within a circle-shaped <img> tag with a border-radius of 50%. The issue arises when trying to display an image fetched from Firebase storage, rather than from a URL. In attempt to solve this problem, ...

Why use rxjs observables if they don't respond to updates?

I have an array of items that I turn into an observable using the of function. I create the observable before populating the array. However, when the array is finally populated, the callback provided to subscribe does not execute. As far as I know, th ...

Subtracting 25% from the width of the web browser

After spending some time trying to solve this issue by myself, I've decided to reach out for help here where I know I can get some great responses. I am looking to determine the dimensions of the browser window minus 25%. Specifically, I have a two-c ...

Error: Uncaught TypeError - The function indexOf is not defined for e.target.className at the mouseup event in HTMLDocument (translator.js:433) within the angular

Upon clicking on an SVG to edit my data in a modal bootstrap, I encountered the following error: Uncaught TypeError: e.target.className.indexOf is not a function at HTMLDocument.mouseup (translator.js:433) This is my SVG code: <svg data-dismiss ...

What is the best way to apply "display: none;" on a span element nested within a title attribute?

I am utilizing the social-share-button gem to share blog posts on social media. The website has been internationalized, making it bilingual (English and German). Everything is functioning correctly, but I encounter an issue with the social share buttons wh ...

Converting object values to strings is a common practice during JSON posting operations

I encountered an issue with a date object when sending it to a NodeJS server. While the object is still preserved, the time gets converted to a string during the process. Is there a way to prevent this conversion? I tried parsing the object but received an ...

The browser is throwing errors because TypeScript is attempting to convert imports to requires during compilation

A dilemma I encountered: <script src="./Snake.js" type="text/javascript"></script> was added to my HTML file. I have a file named Snake.ts which I am compiling to JS using the below configuration: {target: "es6", module: "commonjs"} Howeve ...