Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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? #53

Open
code42099 opened this issue Sep 5, 2019 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@code42099
Copy link

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.
@theseanl
Copy link
Owner

theseanl commented Sep 5, 2019

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!

@code42099
Copy link
Author

You are quite right, now It's worked. thanks theseanl!

@theseanl theseanl added enhancement New feature or request documentation Improvements or additions to documentation and removed enhancement New feature or request labels Sep 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants