Skip to content

Not produce json module to destination directory ? #665

@dimaslanjaka

Description

@dimaslanjaka

Expected behavior: JSON File (resolve json module) not copied into destination directory

Actual behavior: Not copying json files

Environment:

  • node 12.x 14.x
  • typescript 4.4.4 until latest
  • gulp latest (4.x)

Your gulpfile:

Include your gulpfile, or only the related task (with ts.createProject).

import gulpCore from "./src/gulp-core";
import { PostHeader } from "./src/types/post-header";
import { readdirSync } from "fs";
import { join } from "path";
import chalk from "chalk";
import ts from "gulp-typescript";
import gulp from "gulp";
import merge from "merge2";

function defaultTask(cb) {
  gulpCore({
    input: readdirSync(join(__dirname, "xml")).map((xml) => {
      return join(__dirname, "xml", xml);
    }),
    output: "./build/export/gulp",
    callback(content: string, headers: PostHeader): string {
      console.log("gulp process post", chalk.magenta(headers.title));
      return content;
    },
    hostname: ["webmanajemen.com", "web-manajemen.blogspot.com", "dimaslanjaka.github.io"],
  });
  // place code for your default task here
  cb();
}

function compileTs(done) {
  const tsProject = ts.createProject("tsconfig.publish.json");
  const tsResult = tsProject.src().pipe(tsProject());

  return merge([tsResult.dts.pipe(gulp.dest("dist")), tsResult.js.pipe(gulp.dest("dist"))]);
}

exports.default = defaultTask;
exports.tsc = compileTs;

tsconfig.json

Include your tsconfig, if related to this issue.

{
  "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"]
}

Code

Include your TypeScript code, if necessary.

// just import section, the problem is Why not copying json file to destination directory ?
import StringBuilder from "./StringBuilder";
import excludeTitleArr from "./excludeTitle.json";

Source

Screenshot from 2021-11-01 11-36-20

Compiled

Screenshot from 2021-11-01 11-34-32

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions