Open dimaslanjaka opened 2 years ago
@ivogabe: as a step in gradually taking on the maintaining work (#664), can you narrow down the potential problematic zone so I can look into it ?
I guess that the problem is that we don't load JSON files in tsProject.src()
and/or that we don't push .json
files to the output streams (tsResult.js
and the main stream tsResult
).
I guess that the problem is that we don't load JSON files in
tsProject.src()
and/or that we don't push.json
files to the output streams (tsResult.js
and the main streamtsResult
).
I've tried using gulp.src(["src/**/*.{js,ts,json}"])
and tsProject.src(["src/**/*.{js,ts,json}"])
, the result still not copying the json files. And made the program wont run because json not found
.
If i compile with tsc -p tsconfig.publish.json
json file copied successful, but on CI the tsc -p tsconfig.publish.json
EACCESS idk, when i run ls
, the tsconfig.publish.json
exists in lists. [FIXED]
But i tried using gulp because all my compiler using gulp.
Now iam still using local tsc compiler to produce production js files. so it takes more time
Hi,
Have you known why since ?
I've tried using gulp.src(["src/*/.{js,ts,json}"])
This doesn't work either ? because it should, as it only loads the files and do nothing else. I'll look into this asap.
Hi,
Have you known why since ?
1 month ago
Now i copying json files manually with
gulp.src(['src/**/*.json']).pipe(gulp.dest('dist'))
And compiling typescript with gulp-typescript separately. This trick work for now.
Probably the issue is in compiler.ts
then, here you can see that we don't push the json files to any output stream: https://github.com/ivogabe/gulp-typescript/blob/b01326a77347520f1a24a877e3305ae272a1b432/lib/compiler.ts#L154-L174
Thanks for the hint ! Just tested, that's indeed where the problem is.
@dimaslanjaka Can you please revisit what is the behaviour of tsc regarding non js/ts files ?
It this is to be solved, I want to follow tsc's Api.
Thanks for the hint ! Just tested, that's indeed where the problem is.
@dimaslanjaka Can you please revisit what is the behaviour of tsc regarding non js/ts files ?
It this is to be solved, I want to follow tsc's Api.
Sorry i dont understand what u mean.
tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"checkJs": false,
"allowUnusedLabels": true,
"allowSyntheticDefaultImports": true,
"allowUmdGlobalAccess": true,
"allowUnreachableCode": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"experimentalDecorators": true,
"removeComments": false,
"declaration": true,
"declarationMap": false,
"declarationDir": "dist/types",
"outDir": "dist"
},
"include": ["src", "__test__"],
"exclude": ["src/lang"]
}
src/index.ts
import data from './data.json';
console.log(data);
src/data.json
["data1", "data2"]
gulpfile.ts
import ts from "gulp-typescript";
import gulp from "gulp";
function compileTs(done) {
const tsProject = ts.createProject("tsconfig.json");
const tsResult = tsProject.src().pipe(tsProject());
return merge([tsResult.dts.pipe(gulp.dest("dist")), tsResult.js.pipe(gulp.dest("dist"))]);
}
exports.default = defaultTask;
on terminal execute
gulp
is src/data.json
copied into dist/src/data.json
or not ?
is
src/data.json
is copied intodist/src/data.json
or not ?
i tried this 1 month ago, json files not copied into destination tsconfig.json. and the program cannot run because json file not found in compiled directory (dist)
Sorry i dont understand what u mean.
Does tsc
treat all type of non JS/TS files import
the same way ?
Sorry i dont understand what u mean.
Does
tsc
treat all type of non JS/TS filesimport
the same way ?
tsc copying only the json files because of resolveJsonModule: true
on tsconfig.json
I only need the json data that can be imported on js/ts
rather than i modifying the ts variable, i prefer add/remove data on json files.
the problem of this issue is gulp-typescript
not copying json
files into destination directory.
If I use tsc
in the shell, the json file will be copied to the destination folder.
so, iam using this for now.
Now i copying json files manually with
gulp.src(['src/**/*.json']).pipe(gulp.dest('dist'))
And compiling typescript with gulp-typescript separately. This trick work for now.
data in JSON is also useful for specifying an interface or type. for example https://github.com/dimaslanjaka/hexo-seo/blob/compiler/src/html/schema/article/index.ts
Expected behavior: JSON File (resolve json module) not copied into destination directory
Actual behavior: Not copying json files
Environment:
Your gulpfile:
Include your gulpfile, or only the related task (with
ts.createProject
).tsconfig.json
Include your tsconfig, if related to this issue.
Code
Include your TypeScript code, if necessary.
Source
Compiled