+ return
{this.renderSurvey() }
}
diff --git a/testCafe/knockout/bootstrap.html b/testCafe/knockout/bootstrap.html
index 3d92bc6c77..844ab3a745 100644
--- a/testCafe/knockout/bootstrap.html
+++ b/testCafe/knockout/bootstrap.html
@@ -16,8 +16,8 @@
-
-
+
+
diff --git a/testCafe/knockout/standard.html b/testCafe/knockout/standard.html
index 2a1794c2f4..dad160adac 100644
--- a/testCafe/knockout/standard.html
+++ b/testCafe/knockout/standard.html
@@ -13,8 +13,8 @@
-
-
+
+
diff --git a/testCafe/react/bootstrap.html b/testCafe/react/bootstrap.html
index 6cec8cd050..00453cbfb9 100644
--- a/testCafe/react/bootstrap.html
+++ b/testCafe/react/bootstrap.html
@@ -19,8 +19,8 @@
-
-
+
+
diff --git a/testCafe/react/standard.html b/testCafe/react/standard.html
index a4a0cb3b27..77ed10b427 100644
--- a/testCafe/react/standard.html
+++ b/testCafe/react/standard.html
@@ -15,8 +15,8 @@
-
-
+
+
diff --git a/tests/basetests.ts b/tests/basetests.ts
index ee5fa1135c..e28b6a845e 100644
--- a/tests/basetests.ts
+++ b/tests/basetests.ts
@@ -1,6 +1,6 @@
import {ItemValue, Event} from "../src/base";
-QUnit.module("Base");
+export default QUnit.module("Base");
QUnit.test("Event hasEvents property", function (assert) {
var event = new Event<() => any, any>();
diff --git a/tests/choicesRestfulltests.ts b/tests/choicesRestfulltests.ts
index 5fc8ea90ed..f6cfd72678 100644
--- a/tests/choicesRestfulltests.ts
+++ b/tests/choicesRestfulltests.ts
@@ -2,7 +2,7 @@
import {QuestionDropdownModel} from "../src/question_dropdown";
import {ItemValue} from "../src/base";
-QUnit.module("choicesRestfull");
+export default QUnit.module("choicesRestfull");
class ChoicesRestfullTester extends ChoicesRestfull {
public runJson(json: any) {
diff --git a/tests/conditionstests.ts b/tests/conditionstests.ts
index 39d7c8be67..6857474a57 100644
--- a/tests/conditionstests.ts
+++ b/tests/conditionstests.ts
@@ -1,7 +1,7 @@
import {ConditionsParser} from "../src/conditionsParser";
import {Condition, ConditionNode, ConditionRunner} from "../src/conditions";
-QUnit.module("Conditions");
+export default QUnit.module("Conditions");
QUnit.test("Condition", function (assert) {
var op = new Condition();
diff --git a/tests/jsonobjecttests.ts b/tests/jsonobjecttests.ts
index d15e5ca7be..a9f63a8b42 100644
--- a/tests/jsonobjecttests.ts
+++ b/tests/jsonobjecttests.ts
@@ -93,7 +93,7 @@ JsonObject.metaData.addClass("shouldnotcreate", ["A"], function () { return new
JsonObject.metaData.addClass("container", [{ name: "obj", className: "shouldnotcreate" }, { name: "items", className: "shouldnotcreate"}]);
JsonObject.metaData.overrideClassCreatore("shouldnotcreate", function () { return new CreatingObject(); });
-QUnit.module("JsonSerializationTests");
+export default QUnit.module("JsonSerializationTests");
QUnit.test("Metadata for non inherited class", function (assert) {
assert.equal(JsonObject.metaData.getProperties("dealer").length, 9, "Flat properties list");
diff --git a/tests/ko/kosurveymodeltests.ts b/tests/ko/kosurveymodeltests.ts
index 4065de997c..8899ba9066 100644
--- a/tests/ko/kosurveymodeltests.ts
+++ b/tests/ko/kosurveymodeltests.ts
@@ -2,7 +2,7 @@
import {QuestionRating} from "../../src/knockout/koquestion_rating";
import {Survey} from "../../src/knockout/kosurvey";
-QUnit.module("koTests");
+export default QUnit.module("koTests");
QUnit.test("Serialize two pages", function (assert) {
var survey = new Survey();
diff --git a/tests/ko/survey_kotests.ts b/tests/ko/survey_kotests.ts
index 942216abec..4652157170 100644
--- a/tests/ko/survey_kotests.ts
+++ b/tests/ko/survey_kotests.ts
@@ -9,7 +9,7 @@ import {MatrixDropdownColumn} from "../../src/question_matrixdropdownbase";
import {QuestionMultipleText, MultipleTextItem} from "../../src/knockout/koquestion_multipletext";
import {Page} from "../../src/knockout/kopage";
-QUnit.module("koTests");
+export default QUnit.module("koTests");
QUnit.test("Survey.koCurrentPage", function (assert) {
var survey = new Survey();
diff --git a/tests/ko/templatetexttests.ts b/tests/ko/templatetexttests.ts
index 1912a48b6a..3fa01a5472 100644
--- a/tests/ko/templatetexttests.ts
+++ b/tests/ko/templatetexttests.ts
@@ -1,8 +1,8 @@
import {SurveyTemplateText} from "../../src/knockout/templateText";
-QUnit.module("Template Text");
+export default QUnit.module("Template Text");
- export class SurveyTemplateTextTest extends SurveyTemplateText {
+ class SurveyTemplateTextTest extends SurveyTemplateText {
constructor(public template: string) { super(); }
protected get text(): string { return this.template; }
protected set text(value: string) { this.template = value; }
diff --git a/tests/surveyLocalizationTests.ts b/tests/surveyLocalizationTests.ts
index 0c84447ff0..a1040480d5 100644
--- a/tests/surveyLocalizationTests.ts
+++ b/tests/surveyLocalizationTests.ts
@@ -1,7 +1,12 @@
import {surveyLocalization} from "../src/surveyStrings";
import {SurveyModel} from "../src/survey";
-QUnit.module("LocalizationsTests");
+import '../src/localization/russian';
+import '../src/localization/french';
+import '../src/localization/finnish';
+import '../src/localization/german';
+
+export default QUnit.module("LocalizationsTests");
QUnit.test("get default strings", function (assert) {
assert.equal(surveyLocalization.getString("pageNextText"), "Next");
diff --git a/tests/surveyquestiontests.ts b/tests/surveyquestiontests.ts
index c71daef57e..83b7f21598 100644
--- a/tests/surveyquestiontests.ts
+++ b/tests/surveyquestiontests.ts
@@ -13,7 +13,7 @@ import {MatrixDropdownColumn} from "../src/question_matrixdropdownbase";
import {QuestionDropdownModel} from "../src/question_dropdown";
import {QuestionMatrixDynamicModel} from "../src/question_matrixdynamic";
-QUnit.module("Survey_Questions");
+export default QUnit.module("Survey_Questions");
QUnit.test("Only some questions support comment", function (assert) {
var questionText =
QuestionFactory.Instance.createQuestion("text", "textQuestion");
diff --git a/tests/surveyserializationtests.ts b/tests/surveyserializationtests.ts
index 657628c95b..5b1a6f5c82 100644
--- a/tests/surveyserializationtests.ts
+++ b/tests/surveyserializationtests.ts
@@ -7,7 +7,7 @@ import {Question} from "../src/question";
import {QuestionMultipleTextModel, MultipleTextItemModel} from "../src/question_multipletext";
import {QuestionDropdownModel} from "../src/question_dropdown";
-QUnit.module("SurveySerialization");
+export default QUnit.module("SurveySerialization");
QUnit.test("Serialize two pages", function (assert) {
var survey = new SurveyModel();
diff --git a/tests/surveytests.ts b/tests/surveytests.ts
index 64b42ef130..927b303bc2 100644
--- a/tests/surveytests.ts
+++ b/tests/surveytests.ts
@@ -20,7 +20,7 @@ import {QuestionMatrixDropdownModel} from "../src/question_matrixdropdown";
import {QuestionMatrixDynamicModel} from "../src/question_matrixdynamic";
import {QuestionRatingModel} from "../src/question_rating";
-QUnit.module("Survey");
+export default QUnit.module("Survey");
QUnit.test("set data property", function (assert) {
var survey = new SurveyModel();
diff --git a/tests/surveytriggertests.ts b/tests/surveytriggertests.ts
index 807f7a7793..a9796e3f37 100644
--- a/tests/surveytriggertests.ts
+++ b/tests/surveytriggertests.ts
@@ -1,6 +1,6 @@
import {Trigger, ISurveyTriggerOwner, SurveyTriggerVisible} from "../src/trigger";
-QUnit.module("Triggers");
+export default QUnit.module("Triggers");
class TriggerTester extends Trigger {
constructor(public succFunc: Function = null, public failureFunc: Function = null) {
diff --git a/tests/surveyvalidatortests.ts b/tests/surveyvalidatortests.ts
index eefc81adae..ee024565b4 100644
--- a/tests/surveyvalidatortests.ts
+++ b/tests/surveyvalidatortests.ts
@@ -1,6 +1,6 @@
import {NumericValidator, EmailValidator} from "../src/validator";
-QUnit.module("Validators");
+export default QUnit.module("Validators");
QUnit.test("Numeric validator", function (assert) {
var validator = new NumericValidator();
diff --git a/tests/textPreprocessorTests.ts b/tests/textPreprocessorTests.ts
index 6c4e1ecd05..fc098b812c 100644
--- a/tests/textPreprocessorTests.ts
+++ b/tests/textPreprocessorTests.ts
@@ -1,7 +1,7 @@
import {TextPreProcessor} from "../src/textPreProcessor";
import {ProcessValue} from "../src/conditionProcessValue";
-QUnit.module("TextPreprocessorTests");
+export default QUnit.module("TextPreprocessorTests");
QUnit.test("Replace simple names", function (assert) {
var processor = new TextPreProcessor();
diff --git a/tsconfig.json b/tsconfig.json
index b6ef79ef65..240767e0de 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -4,16 +4,12 @@
"module": "es2015",
"sourceMap": true,
"noImplicitAny": false,
- "noEmitHelpers": true,
+ "importHelpers": true,
+ "moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"jsx": "react"
},
"include": [
- "typings/index.d.ts",
"src/**/*.ts"
- ],
- "exclude": [
- "node_modules",
- "**/*.spec.ts"
]
}
\ No newline at end of file
diff --git a/typings.json b/typings.json
deleted file mode 100644
index 0fb864c897..0000000000
--- a/typings.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "surveyjs",
- "globalDependencies": {
- "jquery": "registry:dt/jquery#1.10.0+20161119044246",
- "knockout": "github:DefinitelyTyped/DefinitelyTyped/knockout/knockout.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "node": "registry:dt/node#6.0.0+20161019125345",
- "qunit": "github:DefinitelyTyped/DefinitelyTyped/qunit/qunit.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react": "github:DefinitelyTyped/DefinitelyTyped/react/react.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-addons-create-fragment": "github:DefinitelyTyped/DefinitelyTyped/react/react-addons-create-fragment.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-addons-css-transition-group": "github:DefinitelyTyped/DefinitelyTyped/react/react-addons-css-transition-group.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-addons-linked-state-mixin": "github:DefinitelyTyped/DefinitelyTyped/react/react-addons-linked-state-mixin.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-addons-perf": "github:DefinitelyTyped/DefinitelyTyped/react/react-addons-perf.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-addons-pure-render-mixin": "github:DefinitelyTyped/DefinitelyTyped/react/react-addons-pure-render-mixin.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-addons-test-utils": "github:DefinitelyTyped/DefinitelyTyped/react/react-addons-test-utils.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-addons-transition-group": "github:DefinitelyTyped/DefinitelyTyped/react/react-addons-transition-group.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-addons-update": "github:DefinitelyTyped/DefinitelyTyped/react/react-addons-update.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-dom": "github:DefinitelyTyped/DefinitelyTyped/react/react-dom.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232",
- "react-global": "github:DefinitelyTyped/DefinitelyTyped/react/react-global.d.ts#08ed4e9f1869e37e29514d862e0158b40e550232"
- }
-}
diff --git a/webpack.config.js b/webpack.config.js
new file mode 100644
index 0000000000..a7ff4160b3
--- /dev/null
+++ b/webpack.config.js
@@ -0,0 +1,222 @@
+'use strict';
+
+var webpack = require('webpack');
+var path = require('path');
+var ExtractTextPlugin = require('extract-text-webpack-plugin');
+var dts = require('dts-bundle');
+var rimraf = require('rimraf');
+var GenerateJsonPlugin = require('generate-json-webpack-plugin');
+var packageJson = require('./package.json');
+var fs = require('fs');
+
+var banner = [
+ "surveyjs - Survey JavaScript library v" + packageJson.version,
+ "(c) Andrew Telnov - http://surveyjs.org/",
+ "License: MIT (http://www.opensource.org/licenses/mit-license.php)",
+].join("\n");
+
+// TODO add to dts_bundler
+var dts_banner = ["Type definitions for Survey JavaScript library v" + packageJson.version,
+ "Project: http://surveyjs.org/",
+ "Definitions by: Andrew Telnov ",
+ ""].join("\n");
+
+var platformOptions = {
+ 'react': {
+ externals: {
+ 'react': {
+ root: 'React',
+ commonjs2: 'react',
+ commonjs: 'react',
+ amd: 'react'
+ },
+ 'react-dom': {
+ root: 'ReactDOM',
+ commonjs2: 'react-dom',
+ commonjs: 'react-dom',
+ amd: 'react-dom'
+ }
+ },
+ keywords: ['react', 'react-component'],
+ dependencies: { 'react': '^15.0.1', 'react-dom': '^15.0.1' }
+ },
+ 'knockout': {
+ externals: {
+ 'knockout': {
+ root: 'ko',
+ commonjs2: 'knockout',
+ commonjs: 'knockout',
+ amd: 'knockout'
+ }
+ },
+ keywords: ['knockout'],
+ dependencies: {'knockout': '^3.4.0'}
+ },
+ 'jquery': {
+ externals: {
+ 'jquery': {
+ root: 'jQuery',
+ commonjs2: 'jquery',
+ commonjs: 'jquery',
+ amd: 'jquery'
+ }
+ },
+ keywords: ['jquery', 'jquery-plugin'],
+ dependencies: { 'jquery': '>=1.12.4', '@types/react': '0.0.0' }
+ },
+ 'angular': {
+ externals: {},
+ keywords: ['angular', 'angular-component'],
+ dependencies: { '@types/react': '0.0.0' }
+ }
+};
+
+module.exports = function(options) {
+ var packagePath = './packages/survey-' + options.platform + '/';
+ var extractCSS = new ExtractTextPlugin({ filename: packagePath + 'survey.css' });
+
+ var percentage_handler = function handler(percentage, msg) {
+ if ( 0 == percentage ) {
+ console.log('Build started... good luck!');
+ } else if ( 1 == percentage ) {
+ if (options.buildType === "prod") {
+ dts.bundle({
+ name: '../../survey.' + options.platform,
+ main: packagePath + 'typings/entries/' + options.platform + '.d.ts',
+ outputAsModuleFolder: true,
+ headerText: dts_banner
+ });
+ rimraf.sync(packagePath + 'typings');
+ fs.createReadStream('./npmREADME.md').pipe(fs.createWriteStream(packagePath + 'README.md'));
+ }
+ //TODO someday need to remove
+ if (options.platform === "knockout") {
+ if (options.buildType === "prod") {
+ fs.rename('./packages/survey-knockout/survey.knockout.min.js', './packages/survey-knockout/survey.ko.min.js');
+ fs.rename('./packages/survey-knockout/survey.knockout.d.ts', './packages/survey-knockout/survey.ko.d.ts');
+ } else {
+ fs.rename('./packages/survey-knockout/survey.knockout.js', './packages/survey-knockout/survey.ko.js');
+ }
+ }
+ }
+ };
+
+ var packagePlatformJson = {
+ 'name': 'survey-' + options.platform,
+ 'version': packageJson.version,
+ 'description': 'survey.js is a JavaScript Survey Library. It is a modern way to add a survey to your website. It uses JSON for survey metadata and results.',
+ 'keywords': [
+ 'Survey',
+ 'JavaScript',
+ 'Bootstrap',
+ 'Library'
+ ].concat(platformOptions[options.platform].keywords),
+ 'homepage': 'https://surveyjs.org/',
+ 'license': 'MIT',
+ 'files': [
+ 'survey.css',
+ 'survey.min.css',
+ 'survey.' + options.platform + '.js',
+ 'survey.' + options.platform + '.min.js'
+ ],
+ 'main': [
+ 'survey.min.css',
+ 'survey.' + options.platform + '.min.js'
+ ],
+ 'repository': {
+ 'type': 'git',
+ 'url': 'https://github.com/andrewtelnov/surveyjs.git'
+ },
+ 'typings': 'survey.' + options.platform + '.d.ts',
+ 'dependencies': platformOptions[options.platform].dependencies
+ };
+
+ var config = {
+ entry: {},
+ resolve: {
+ extensions: ['.ts', '.tsx', '.scss']
+ },
+ module: {
+ rules: [
+ {
+ test: /\.(ts|tsx)$/,
+ loader: 'ts-loader',
+ options: {
+ compilerOptions: {
+ 'declaration': options.buildType === 'prod',
+ 'outDir': packagePath + 'typings/'
+ }
+ }
+ },
+ {
+ test: /\.scss$/,
+ loader: extractCSS.extract({
+ fallbackLoader: 'style-loader',
+ loader: 'css-loader!sass-loader'
+ })
+ },
+ {
+ test: /\.html$/,
+ loader: 'html-loader'
+ }
+ ]
+ },
+ output: {
+ filename: packagePath + '[name]' + (options.buildType === 'prod' ? '.min': '') + '.js',
+ library: 'Survey',
+ libraryTarget: 'umd',
+ umdNamedDefine: true
+ },
+ externals: platformOptions[options.platform].externals,
+ plugins: [
+ new webpack.ProgressPlugin(percentage_handler),
+ extractCSS
+ ],
+ devtool: 'inline-source-map'
+ };
+
+ if (options.platform === 'angular' || options.platform === 'jquery') {
+ config.resolve.alias = {
+ 'react': 'preact-compat',
+ 'react-dom': 'preact-compat'
+ };
+
+ // TODO because of preact-compat https://github.com/developit/preact-compat/issues/192 need to better decision
+ config.module.rules.push({
+ loader: 'babel-loader',
+ include: [
+ path.join(__dirname, './node_modules/preact-compat/src'),
+ ],
+ options: {
+ presets: [
+ ['latest', { modules: false }],
+ ],
+ },
+ });
+ // EO TODO
+ }
+
+ if (options.buildType === 'prod') {
+ config.devtool = false;
+ config.plugins = config.plugins.concat([
+ new webpack.optimize.UglifyJsPlugin(),
+ new webpack.BannerPlugin(banner),
+ new GenerateJsonPlugin(
+ packagePath + 'package.json',
+ packagePlatformJson,
+ undefined,
+ 2
+ )
+ ]);
+ }
+
+ if (options.buildType === 'dev') {
+ config.plugins = config.plugins.concat([
+ new webpack.LoaderOptionsPlugin({ debug: true})
+ ]);
+ }
+
+ config.entry['survey.' + options.platform] = path.resolve(__dirname, './src/entries/' + options.platform);
+
+ return config;
+};
\ No newline at end of file
diff --git a/webpack/webpack.config.js b/webpack/webpack.config.js
deleted file mode 100644
index 69cda59d44..0000000000
--- a/webpack/webpack.config.js
+++ /dev/null
@@ -1,78 +0,0 @@
-'use strict';
-
-var webpack = require('webpack');
-var path = require('path');
-
-module.exports = function(options) {
- var babelConfig = {
- presets: [
- [require.resolve('babel-preset-es2015'), { loose: true }],
- require.resolve('babel-preset-react')
- ]
- };
-
- var config = {
- resolveLoader: {root: path.join(__dirname, 'node_modules')},
- resolve: {
- extensions: ['', '.ts', '.tsx']
- },
- entry: {},
- output: {
- filename: '[name].js',
- library: 'Survey',
- libraryTarget: 'umd',
- umdNamedDefine: true
- },
- externals: {
- 'react': {
- root: 'React',
- commonjs2: 'react',
- commonjs: 'react',
- amd: 'react'
- },
- 'react-dom': {
- root: 'ReactDOM',
- commonjs2: 'react-dom',
- commonjs: 'react-dom',
- amd: 'react-dom'
- },
- 'knockout': {
- root: 'ko',
- commonjs2: 'knockout',
- commonjs: 'knockout',
- amd: 'knockout'
- }
- },
- module: {
- preLoaders: [
- { test: /\.(js|jsx)$/, loader: "source-map-loader" }
- ],
- loaders: [
- {
- test: /\.(ts|tsx)$/,
- loaders:[
- require.resolve('babel-loader') + '?' + JSON.stringify(babelConfig), // TODO why do we need it
- require.resolve('ts-loader')
- ]
- },
- {
- test: /\.(js|jsx)$/,
- loader: require.resolve('babel-loader'),
- query: babelConfig
- }
- ]
- },
- debug: true,
- plugins: [
- new webpack.NoErrorsPlugin(),
- new webpack.ProvidePlugin({
- __extends: path.join(__dirname, '../src', 'extends.ts')
- })
- ],
- devtool: 'inline-source-map'
- };
-
- config.entry[options.bundleName] = path.resolve(__dirname, options.entryPoint);
-
- return config;
-};
\ No newline at end of file
diff --git a/webpack/webpack.universal.config.js b/webpack/webpack.universal.config.js
deleted file mode 100644
index 11a2ea9a4a..0000000000
--- a/webpack/webpack.universal.config.js
+++ /dev/null
@@ -1,78 +0,0 @@
-'use strict';
-
-var webpack = require('webpack');
-var path = require('path');
-
-module.exports = function(options) {
- var babelConfig = {
- presets: [
- 'latest',
- 'stage-0',
- 'react'
- ],
- plugins: [
- 'transform-react-remove-prop-types',
- 'transform-react-constant-elements'
- ]
- };
-
- var config = {
- resolveLoader: {root: path.join(__dirname, 'node_modules')},
- resolve: {
- alias: {
- 'react': 'preact-compat',
- 'react-dom': 'preact-compat'
- },
- extensions: ['', '.ts', '.tsx']
- },
- entry: {},
- output: {
- filename: '[name].js',
- library: 'Survey',
- libraryTarget: 'umd',
- umdNamedDefine: true
- },
- externals: {
- 'jquery': {
- root: 'jQuery',
- commonjs2: 'jquery',
- commonjs: 'jquery',
- amd: 'jquery'
- }
- },
- module: {
- preLoaders: [
- { test: /\.(js|jsx)$/, loader: "source-map-loader" }
- ],
- loaders: [
- {
- test: /\.(ts|tsx)$/,
- exclude: /node_modules/,
- loaders:[
- require.resolve('babel-loader') + '?' + JSON.stringify(babelConfig), // TODO why do we need it
- require.resolve('ts-loader')
- ]
- },
- {
- test: /\.(js|jsx)$/,
- loader: require.resolve('babel-loader'),
- exclude: /node_modules/,
- query: babelConfig
- }
- ]
- },
- debug: true,
- plugins: [
- new webpack.NoErrorsPlugin(),
- new webpack.ProvidePlugin({
- __extends: path.join(__dirname, '../src', 'extends.ts'),
- __assign: path.join(__dirname, '../src', 'assign.ts')
- })
- ],
- devtool: 'inline-source-map'
- };
-
- config.entry[options.bundleName] = path.resolve(__dirname, options.entryPoint);
-
- return config;
-};
\ No newline at end of file