Skip to content

Commit

Permalink
work for #5312 Generate .d.ts the same way in windows/linux (#5318)
Browse files Browse the repository at this point in the history
Co-authored-by: OlgaLarina <[email protected]>
  • Loading branch information
OlgaLarina and OlgaLarina authored Dec 8, 2022
1 parent c8b5dab commit e0c815b
Show file tree
Hide file tree
Showing 12 changed files with 130 additions and 28 deletions.
11 changes: 10 additions & 1 deletion build-scripts/survey-angular/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
const { merge } = require("webpack-merge");
var packageJson = require("./package.json");
var path = require("path");
Expand All @@ -12,7 +13,15 @@ const config = {
defaultV2: path.resolve(__dirname, "../../src/defaultV2-theme/defaultV2.scss")
},
externals: {
}
},
plugins: [
new DtsGeneratorPlugin({
tsConfigPath: "./build-scripts/survey-angular/tsconfig.typing.angular.json",
filePath: "build/survey-angular/survey-angular.d.ts",
moduleName: "survey-angular",
importName: "entries/angular"
}),
],
};

module.exports = function (options) {
Expand Down
11 changes: 10 additions & 1 deletion build-scripts/survey-core/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
const { merge } = require("webpack-merge");
var packageJson = require("./package.json");
var FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries");
Expand All @@ -15,7 +16,15 @@ const config = {
defaultV2: path.resolve(__dirname, "../../src/defaultV2-theme/defaultV2.scss"),
"defaultV2.fontless": path.resolve(__dirname, "../../src/defaultV2-theme/defaultV2.fontless.scss")
},
plugins: [new FixStyleOnlyEntriesPlugin()],
plugins: [
new FixStyleOnlyEntriesPlugin(),
new DtsGeneratorPlugin({
tsConfigPath: "./build-scripts/survey-core/tsconfig.typing.json",
filePath: "build/survey-core/survey.core.d.ts",
moduleName: "survey-core",
importName: "entries/core"
}),
],
};

module.exports = function (options) {
Expand Down
11 changes: 10 additions & 1 deletion build-scripts/survey-jquery/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
const { merge } = require("webpack-merge");
var packageJson = require("./package.json");
var path = require("path");
Expand All @@ -18,7 +19,15 @@ const config = {
commonjs: "jquery",
amd: "jquery"
}
}
},
plugins: [
new DtsGeneratorPlugin({
tsConfigPath: "./build-scripts/survey-jquery/tsconfig.typing.jquery.json",
filePath: "build/survey-jquery/survey-jquery.d.ts",
moduleName: "survey-jquery",
importName: "entries/jquery"
}),
],
};

module.exports = function (options) {
Expand Down
11 changes: 10 additions & 1 deletion build-scripts/survey-knockout-ui/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
const { merge } = require("webpack-merge");
var packageJson = require("./package.json");

Expand All @@ -18,7 +19,15 @@ const config = {
commonjs: "survey-core",
amd: "survey-core"
}
}
},
plugins: [
new DtsGeneratorPlugin({
tsConfigPath: "./build-scripts/survey-knockout-ui/tsconfig.typing.ko-ui.json",
filePath: "build/survey-knockout-ui/survey-knockout-ui.d.ts",
moduleName: "survey-knockout-ui",
importName: "entries/knockout-ui-model"
}),
],
};

module.exports = function (options) {
Expand Down
11 changes: 10 additions & 1 deletion build-scripts/survey-knockout/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
const { merge } = require("webpack-merge");
var packageJson = require("./package.json");
var path = require("path");
Expand All @@ -18,7 +19,15 @@ const config = {
commonjs: "knockout",
amd: "knockout"
}
}
},
plugins: [
new DtsGeneratorPlugin({
tsConfigPath: "./build-scripts/survey-knockout/tsconfig.typing.ko.json",
filePath: "build/survey-knockout/survey-knockout.d.ts",
moduleName: "survey-knockout",
importName: "entries/knockout"
}),
],
};

module.exports = function (options) {
Expand Down
11 changes: 10 additions & 1 deletion build-scripts/survey-react-ui/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
const { merge } = require("webpack-merge");
var packageJson = require("./package.json");

Expand All @@ -24,7 +25,15 @@ const config = {
commonjs: "survey-core",
amd: "survey-core"
}
}
},
plugins: [
new DtsGeneratorPlugin({
tsConfigPath: "./build-scripts/survey-react-ui/tsconfig.typing.react-ui.json",
filePath: "build/survey-react-ui/survey-react-ui.d.ts",
moduleName: "survey-react-ui",
importName: "entries/react-ui-model"
}),
],
};

module.exports = function (options) {
Expand Down
11 changes: 10 additions & 1 deletion build-scripts/survey-react/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
const { merge } = require("webpack-merge");
var packageJson = require("./package.json");
var path = require("path");
Expand All @@ -24,7 +25,15 @@ const config = {
commonjs: "react-dom",
amd: "react-dom"
}
}
},
plugins: [
new DtsGeneratorPlugin({
tsConfigPath: "./build-scripts/survey-react/tsconfig.typing.react.json",
filePath: "build/survey-react/survey-react.d.ts",
moduleName: "survey-react",
importName: "entries/react"
}),
],
};

module.exports = function (options) {
Expand Down
12 changes: 11 additions & 1 deletion build-scripts/survey-vue-ui/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
const { merge } = require("webpack-merge");
var packageJson = require("./package.json");

Expand All @@ -18,7 +19,16 @@ const config = {
commonjs: "survey-core",
amd: "survey-core"
}
}
},
plugins: [
new DtsGeneratorPlugin({
tsCommand: "vue-tsc --project",
tsConfigPath: "./build-scripts/survey-vue-ui/tsconfig.typing.vue-ui.json",
filePath: "build/survey-vue-ui/survey-vue-ui.d.ts",
moduleName: "survey-vue-ui",
importName: "entries/vue-ui-model"
}),
],
};

module.exports = function (options) {
Expand Down
12 changes: 11 additions & 1 deletion build-scripts/survey-vue/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use strict";

const webpackCommonConfigCreator = require("../webpack.common");
const DtsGeneratorPlugin = require("../webpack-dts-generator");
const { merge } = require("webpack-merge");
var packageJson = require("./package.json");
var path = require("path");
Expand All @@ -18,7 +19,16 @@ const config = {
commonjs: "vue",
amd: "vue"
}
}
},
plugins: [
new DtsGeneratorPlugin({
tsCommand: "vue-tsc --project",
tsConfigPath: "./build-scripts/survey-vue/tsconfig.typing.vue.json",
filePath: "build/survey-vue/survey-vue.d.ts",
moduleName: "survey-vue",
importName: "entries/vue"
}),
],
};

module.exports = function (options) {
Expand Down
22 changes: 22 additions & 0 deletions build-scripts/webpack-dts-generator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';
const webpack = require("webpack");
const fs = require('fs');
const child_process = require('child_process');

module.exports = function DtsGeneratorProgressPlugin(options) {
return new webpack.ProgressPlugin(function(progress) {
if (progress === 1) {
console.log("typescript start");
const tsConfigPath = options.tsConfigPath || "tsconfig.typing.json";
const tsCommand = options.tsCommand || "tsc --p";
const command = tsCommand + " " + tsConfigPath;
console.log("tsc command is \"" + command + "\"");
child_process.execSync(command);
console.log("typescript end");

const content = "\ndeclare module \"" + options.moduleName + "\" { import main = require(\"" + options.importName + "\"); export = main; }";
console.log("\"" + content + "\"");
fs.writeFile(options.filePath, content, { flag: 'a' }, err => { if(err) { console.error(err); } });
}
});
};
1 change: 0 additions & 1 deletion build-scripts/webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ const VueLoaderPlugin = require("vue-loader/lib/plugin");
var GenerateJsonPlugin = require("generate-json-webpack-plugin");
var DashedNamePlugin = require("./webpack-dashed-name");

var rimraf = require("rimraf");
var packageJsonWithVersion = require("../package.json");
var fs = require("fs");
var replace = require("replace-in-file");
Expand Down
34 changes: 16 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
"build_vue_prod": "webpack --config ./build-scripts/survey-vue/webpack.config.js --env.buildType prod",
"build_jquery_dev": "webpack --config ./build-scripts/survey-jquery/webpack.config.js --env.buildType dev",
"build_jquery_prod": "webpack --config ./build-scripts/survey-jquery/webpack.config.js --env.buildType prod",
"build-jquery-typings:linux": "tsc --p ./build-scripts/survey-jquery/tsconfig.typing.jquery.json && echo \"declare module 'survey-jquery' { import main = require('entries/jquery'); export = main; }\" >> build/survey-jquery/survey-jquery.d.ts",
"build-jquery-typings:windows": "tsc --p ./build-scripts/survey-jquery/tsconfig.typing.jquery.json && echo declare module 'survey-jquery' { import main = require('entries/jquery'); export = main; } >> build/survey-jquery/survey-jquery.d.ts",
"build-jquery-typings:linux": "",
"build-jquery-typings:windows": "",
"build_angular_dev": "webpack --config ./build-scripts/survey-angular/webpack.config.js --env.buildType dev",
"build_angular_prod": "webpack --config ./build-scripts/survey-angular/webpack.config.js --env.buildType prod",
"build-angular-typings:linux": "tsc --p ./build-scripts/survey-angular/tsconfig.typing.angular.json && echo \"declare module 'survey-angular' { import main = require('entries/angular'); export = main; }\" >> build/survey-angular/survey-angular.d.ts",
"build-angular-typings:windows": "tsc --p ./build-scripts/survey-angular/tsconfig.typing.angular.json && echo declare module 'survey-angular' { import main = require('entries/angular'); export = main; } >> build/survey-angular/survey-angular.d.ts",
"build-angular-typings:linux": "",
"build-angular-typings:windows": "",
"build_i18n_dev": "webpack --config ./build-scripts/survey-core/webpack.i18n.js --env.buildType dev",
"build_i18n_prod": "webpack --config ./build-scripts/survey-core/webpack.i18n.js --env.buildType prod",
"build_dev": "concurrently \"npm run build_knockout_dev\" \"npm run build_react_dev\" \"npm run build_angular_dev\" \"npm run build_jquery_dev\" \"npm run build_vue_dev\" \"npm run build_core_dev\" \"npm run build_i18n_dev\"",
Expand All @@ -41,26 +41,24 @@
"watch_jquery_dev": "webpack --config ./build-scripts/survey-jquery/webpack.config.js --env.buildType dev --watch",
"watch_vue_dev": "webpack --config ./build-scripts/survey-vue/webpack.config.js --env.buildType dev --watch",
"build_knockout": "npm run build_knockout_dev && npm run build_knockout_prod",
"build-knockout-typings:linux": "tsc --p ./build-scripts/survey-knockout/tsconfig.typing.ko.json && echo \"declare module 'survey-knockout' { import main = require('entries/knockout'); export = main; }\" >> build/survey-knockout/survey-knockout.d.ts",
"build-knockout-typings:windows": "tsc --p ./build-scripts/survey-knockout/tsconfig.typing.ko.json && echo declare module 'survey-knockout' { import main = require('entries/knockout'); export = main; } >> build/survey-knockout/survey-knockout.d.ts",
"build-knockout-typings:linux": "",
"build-knockout-typings:windows": "",
"build_knockout_ui": "webpack --config ./build-scripts/survey-knockout-ui/webpack.config.js --env.buildType dev && webpack --config ./build-scripts/survey-knockout-ui/webpack.config.js --env.buildType prod",
"build-knockout-ui-typings:linux": "tsc --p ./build-scripts/survey-knockout-ui/tsconfig.typing.ko-ui.json && echo \"declare module 'survey-knockout-ui' { import main = require('entries/knockout-ui-model'); export = main; }\" >> build/survey-knockout-ui/survey-knockout-ui.d.ts",
"build-knockout-ui-typings:windows": "tsc --p ./build-scripts/survey-knockout-ui/tsconfig.typing.ko-ui.json && echo declare module 'survey-knockout-ui' { import main = require('entries/knockout-ui-model'); export = main; } >> build/survey-knockout-ui/survey-knockout-ui.d.ts",
"build-knockout-ui-typings:linux": "",
"build-knockout-ui-typings:windows": "",
"build_react": "npm run build_react_dev && npm run build_react_prod",
"build-react-typings:linux": "tsc --p ./build-scripts/survey-react/tsconfig.typing.react.json && echo \"declare module 'survey-react' { import main = require('entries/react'); export = main; }\" >> build/survey-react/survey-react.d.ts",
"build-react-typings:windows": "tsc --p ./build-scripts/survey-react/tsconfig.typing.react.json && echo declare module 'survey-react' { import main = require('entries/react'); export = main; } >> build/survey-react/survey-react.d.ts",
"build-react-typings:linux": "",
"build-react-typings:windows": "",
"build_react_ui": "webpack --config ./build-scripts/survey-react-ui/webpack.config.js --env.buildType dev && webpack --config ./build-scripts/survey-react-ui/webpack.config.js --env.buildType prod",
"build-react-ui-typings:linux": "tsc --p ./build-scripts/survey-react-ui/tsconfig.typing.react-ui.json && echo \"declare module 'survey-react-ui' { import main = require('entries/react-ui-model'); export = main; }\" >> build/survey-react-ui/survey-react-ui.d.ts",
"build-react-ui-typings:windows": "tsc --p ./build-scripts/survey-react-ui/tsconfig.typing.react-ui.json && echo declare module 'survey-react-ui' { import main = require('entries/react-ui-model'); export = main; } >> build/survey-react-ui/survey-react-ui.d.ts",
"build-react-ui-typings:linux": "",
"build-react-ui-typings:windows": "",
"build_vue": "npm run build_vue_dev && npm run build_vue_prod",
"build-vue-typings": "vue-tsc --project ./build-scripts/survey-vue/tsconfig.typing.vue.json",
"build-vue-typings": "",
"build_vue_ui": "webpack --config ./build-scripts/survey-vue-ui/webpack.config.js --env.buildType dev && webpack --config ./build-scripts/survey-vue-ui/webpack.config.js --env.buildType prod",
"build-vue-ui-typings": "vue-tsc --project ./build-scripts/survey-vue-ui/tsconfig.typing.vue-ui.json",
"build-vue-ui-typings": "",
"build_core": "npm run build_core_dev && npm run build_core_prod",
"build-core-typings:linux": "tsc --p ./build-scripts/survey-core/tsconfig.typing.json && echo \"declare module 'survey-core' { import main = require('entries/core'); export = main; }\" >> build/survey-core/survey.core.d.ts",
"build-core-typings:windows": "tsc --p ./build-scripts/survey-core/tsconfig.typing.json && echo declare module 'survey-core' { import main = require('entries/core'); export = main; } >> build/survey-core/survey.core.d.ts",
"build-all-ui-typings:windows": "npm run build-core-typings:windows && npm run build-knockout-ui-typings:windows && npm run build-react-ui-typings:windows && npm run build-vue-ui-typings",
"build-all-not-ui-typings:windows": "npm run build-core-typings:windows && npm run build-knockout-typings:windows && npm run build-react-typings:windows && npm run build-vue-typings && npm run build-jquery-typings:windows && npm run build-angular-typings:windows",
"build-core-typings:linux": "",
"build-core-typings:windows": "",
"build-plugins": "",
"build_i18n": "npm run build_i18n_dev && npm run build_i18n_prod",
"build_jquery": "npm run build_jquery_dev && npm run build_jquery_prod",
Expand Down

0 comments on commit e0c815b

Please sign in to comment.