I'm trying to establish if tscc would be a suitable tool for building Blockly, which is currently built using tsc and Closure Compiler (running in SIMPLE_OPTIMIZATIONS mode in part due to incompatibility between tsc output for enum and Closure Compiler's prohibition on quoting property names—presumably one of the motivations for the creation of tscikle in the first place).
At the moment I have checked out our develop branch and am trying to compile our advanced compilation test (which verifies that Blockly can be built using ADVANCED_OPTIMIZATIONS) by modifying our tsconfig.json to:
{
"include": [
"core/**/*",
"closure/**/*",
"tests/compile/**/*", // Added for advanced compilation test.
],
"exclude": [
"core/blockly.js"
],
"compilerOptions": {
"allowJs": true,
"sourceMap": true,
"module": "ES2015",
"moduleResolution": "node",
"target": "ES2020",
"strict": true,
}
}
and added a simple tscc.spec.json:
{
"modules": {
"out": "tests/compile/main.js"
},
"prefix": "build/"
}
Unfortunately, running tscc generates errors for each .js file included in the build:
TSCC: Module option is set. tsickle converts TypeScript modules to Closure modulesvia CommonJS internally, so it will be overridden to "commonjs".
TSCC: tsickle uses a custom tslib optimized for closure compiler. importHelpers flag is set.
TS: error TS5055: Cannot write file '/Users/cpcallen/src/blockly/closure/goog/base.js' because it would overwrite input file.
error TS5055: Cannot write file '/Users/cpcallen/src/blockly/closure/goog/base_minimal.js' because it would overwrite input file.
error TS5055: Cannot write file '/Users/cpcallen/src/blockly/closure/goog/goog.js' because it would overwrite input file.
error TS5055: Cannot write file '/Users/cpcallen/src/blockly/core/main.js' because it would overwrite input file.
error TS5055: Cannot write file '/Users/cpcallen/src/blockly/tests/compile/main.js' because it would overwrite input file.
error TS5055: Cannot write file '/Users/cpcallen/src/blockly/tests/compile/main_compressed.js' because it would overwrite input file.
error TS5055: Cannot write file '/Users/cpcallen/src/blockly/tests/compile/test_blocks.js' because it would overwrite input file.
node_modules/@types/node/globals.d.ts(42,13): error TS2403: Subsequent variable declarations must have the same type. Variable 'gc' must be of type 'cc', but here has type '(() => void) | undefined'.
TSCC: The compilation has terminated with an error.
I tired using tsc's -outputDir` flag, but this just generated a warning that it was ignored:
$ npx tscc -- -outDir build/src
TSCC: Module option is set. tsickle converts TypeScript modules to Closure modulesvia CommonJS internally, so it will be overridden to "commonjs".
TSCC: --outDir option is set, but it is no-op for tscc.Use prefix option in spec file to control output directory.
...
which is why I added the prefix directive totscc.spec.json. But it appears that prefix is applied only to the output of closure compiler, not the output of tsc.
How can I build a project containing a mix of .ts and .js input files? Given that base.js is mandatory for Closure-based projects, this is presumably supported somehow.
I'm trying to establish if
tsccwould be a suitable tool for building Blockly, which is currently built usingtscand Closure Compiler (running inSIMPLE_OPTIMIZATIONSmode in part due to incompatibility betweentscoutput forenumand Closure Compiler's prohibition on quoting property names—presumably one of the motivations for the creation of tscikle in the first place).At the moment I have checked out our
developbranch and am trying to compile our advanced compilation test (which verifies that Blockly can be built usingADVANCED_OPTIMIZATIONS) by modifying ourtsconfig.jsonto:{ "include": [ "core/**/*", "closure/**/*", "tests/compile/**/*", // Added for advanced compilation test. ], "exclude": [ "core/blockly.js" ], "compilerOptions": { "allowJs": true, "sourceMap": true, "module": "ES2015", "moduleResolution": "node", "target": "ES2020", "strict": true, } }and added a simple
tscc.spec.json:{ "modules": { "out": "tests/compile/main.js" }, "prefix": "build/" }Unfortunately, running tscc generates errors for each
.jsfile included in the build:I tired using
tsc's -outputDir` flag, but this just generated a warning that it was ignored:which is why I added the
prefixdirective totscc.spec.json. But it appears thatprefixis applied only to the output of closure compiler, not the output oftsc.How can I build a project containing a mix of
.tsand.jsinput files? Given thatbase.jsis mandatory for Closure-based projects, this is presumably supported somehow.