tscc
tscc copied to clipboard
Can you put a simple worked project with all the nessesary configure files,configure options, etc, so we can try and figureout the right way to use it?
Hi, I'm very interested in tscc project, but failed to work it out. I followed these steps on your manual to setup a simple project and tried to use tscc to compile.
my_project
├───tsconfig.json
├───rollup.config.js
└───src
├───Components
│ ...
└───app.ts
Install tscc cli:
yarn global add @tscc/tscc
Create a spec file tscc.spec.json next to tsconfig.json.
{
"modules": {
"out": "src/app.ts" // entry file path
}
}
Execute at the project root:
tscc
result screen
> $ tscc
> TSCC: tsickle uses a custom tslib optimized for closure compiler. importHelpers flag is set.
> - Closure Compiler
> (node:10168) ExperimentalWarning: The fs.promises API is experimental
>
> Administrator@MINGW64 ~/app/tsickle/tt
> $
only a empty out.js file is created in my_project folder.
Can you put a simple worked project with all the nessesary configure files,configure options, etc, so we can try and figureout the right way to use it?
Many thanks! 9/5/2019
The project has followings files src/app.ts:
/**
* @param name {string}
* @return {string}
*/
export const getGreeting = (name: string): string => {
return "hello " + name;
};
tsconfig.json:
{
"compilerOptions": {
"lib": [
"es7"
],
"types": [
"node"
],
"target": "es2017",
"module": "commonjs",
"experimentalDecorators": true,
"declaration": false,
"stripInternal": true
}
}
tscc.spec.json:
{
"modules": {
"out": "./src/app.ts"
}
}
Created Result files:
out.js:
only two empty lines, without any charactor,symbols.
.tscc_temp\700d5d6d38f3a92d76761fcecf223eed01bc67e2a2f63b5bbd22bbf9f4bd0633\externs_generated.js:
/**
* @externs
* @suppress {duplicate,checkTypes}
*/
// NOTE: generated by tsickle, do not edit.
Hi, first of all, your configuration looks good. It's just that app.ts file contains a single function that is called nowhere, so Closure Compiler is removing the function declaration and is producing an empty file. In order to use Closure Compiler (and hence tscc), your are expected to compile all of your source files together, so you can include another file that imports and calls getGreeting to the sources. Another way to keep the function in the compiled output is to assign the function to a global variable, e.g. by adding window.getGreeting = getGreeting.
Regarding a simple starter project, I think I can make something similar to rollup/rollup-starter-code-splitting. Also there are some sample configurations in the todomvc repo, hope this helps!
You are quite right, now It's worked. thanks theseanl!