TypeScript project package question

< H1 > question < / H1 >

first describe the problem: the current project uses TypeScript, to configure tsconfig.json. Then use webpack + ts-loader to package.

now I"d like to ask what tsconfig.json and ts-loader do, and whether you need to add the explanation that babel-loader, wants to be familiar with the build tool.

// tsconfig.json
{
    "compilerOptions": {
        "noImplicitAny": true,
        "target": "es5",
        "module": "commonjs",
        "outDir": "tsdist/",
        "sourceMap": true,
        "jsx": "react",
        "allowJs": true,
        "typeRoots": [
            "./node_modules/@types"
        ],
        "lib": [
            "es6",
            "dom",
            "scripthost"
        ]
    },
    "include": [
        "tslib/**/*",
        "tssrc/**/*"
    ]
}

has been packaged as es5, so you don't need babel-loader


tsconfig.json is a configuration file that configures how the compiler of typescript works
ts-loader is a loader, of webpack. When webpack encounters a .ts file, it is called to process

.

ts-loader calls typescript to compile .ts, and typescript reads the tsconfig.json configuration to decide how to compile

.

the above is general and not entirely accurate, but don't worry about the details

finally, if you don't use the features of Stage 1 Stage 2, you should not need to add babel-loader.


loader is commonly known as the loader. In webpack.config.js , you can definitely see where ts-loader is used, indicating that this function is once again, mainly to parse ts | tsx (react) files

.

tsconfig.json tells you what kind of configuration typescript uses to parse and compile your files, that is, your project, because your project must have packaged typescript this package, that it will automatically look for this file in the root directory, and then compile according to your configuration requirements.

babel-loader is the most used on js, his general rules in the configuration file are used to parse the .js file, according to your .babelrc or configuration file to parse your js file, in order to meet your configuration requirements.

I don't know if you can understand it. In fact, take a look at it and thank you. You will understand if you visit these questions and answers.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30c23-2b4b9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30c23-2b4b9.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?