diff --git a/developer/js/.gitignore b/developer/js/.gitignore
index b947077876..bbbfd24cf5 100644
--- a/developer/js/.gitignore
+++ b/developer/js/.gitignore
@@ -1,2 +1,5 @@
node_modules/
dist/
+dist-tests/
+tsconfig.tsbuildinfo
+tests/tsconfig.tsbuildinfo
diff --git a/developer/js/build.sh b/developer/js/build.sh
index 4182fd6088..4b9747a99a 100755
--- a/developer/js/build.sh
+++ b/developer/js/build.sh
@@ -94,6 +94,8 @@ type npm >/dev/null ||\
if (( install_dependencies )) ; then
verify_npm_setup
+ # We need to build web-environment with a script for now
+ "$KEYMAN_ROOT/resources/web-environment/build.sh" || fail "Could not build web-environment"
fi
build || fail "Compilation failed."
diff --git a/developer/js/package.json b/developer/js/package.json
index bfde9a39d3..91b2583b72 100644
--- a/developer/js/package.json
+++ b/developer/js/package.json
@@ -10,7 +10,7 @@
],
"scripts": {
"build": "tsc -b",
- "test": "mocha",
+ "test": "cd tests && tsc -b && cd .. && mocha",
"prepublishOnly": "npm run build"
},
"repository": {
@@ -56,7 +56,6 @@
"ts-node": "^9.1.1"
},
"mocha": {
- "require": "ts-node/register",
- "spec": "tests/**/test-*.ts"
+ "spec": "dist-tests/**/test-*.js"
}
}
diff --git a/developer/js/source/lexical-model-compiler/model-definitions.ts b/developer/js/source/lexical-model-compiler/model-definitions.ts
index 25f1bc1ad2..8ac75267f8 100644
--- a/developer/js/source/lexical-model-compiler/model-definitions.ts
+++ b/developer/js/source/lexical-model-compiler/model-definitions.ts
@@ -3,6 +3,8 @@ import { defaultApplyCasing,
defaultSearchTermToKey
} from "./model-defaults";
+const KEYMAN_VERSION = require("@keymanapp/keyman-version");
+
/**
* Processes certain defined model behaviors in such a way that the needed closures
* may be safely compiled to a JS file and loaded within the LMLayer.
diff --git a/developer/js/tests/helpers/index.ts b/developer/js/tests/helpers/index.ts
index 3719548037..e8039d00be 100644
--- a/developer/js/tests/helpers/index.ts
+++ b/developer/js/tests/helpers/index.ts
@@ -1,4 +1,4 @@
-///
+///
/**
* Helpers and utilities for the Mocha tests.
@@ -16,14 +16,14 @@ export interface CompilationResult {
/**
* Builds a path to the fixture with the given path components.
- *
+ *
* e.g., makePathToFixture('example.qaa.trivial')
* e.g., makePathToFixture('example.qaa.trivial', 'model.ts')
- *
+ *
* @param components One or more path components.
*/
export function makePathToFixture(...components: string[]): string {
- return path.join(__dirname, '..', 'fixtures', ...components);
+ return path.join(__dirname, '..', '..', 'tests', 'fixtures', ...components);
}
/**
@@ -132,7 +132,7 @@ export class LogHoarder {
clear() {
this.messages = [];
}
-
+
/**
* Hoards a log message for later perusal.
*/
@@ -159,7 +159,7 @@ export class LogHoarder {
/**
* Overrides the global log handler, allowing one to browse log messages
* later.
- *
+ *
* Remember to uninstall the log handler afterwards!
*/
install(): this {
@@ -169,7 +169,7 @@ export class LogHoarder {
/**
* Return the log message handler to its default.
- *
+ *
* Note: You MUST uninstall the hoarder after use!
* It's recommended you put this in an afterEach() callback.
*/
diff --git a/developer/js/tests/test-compile-model-with-pseudoclosure.ts b/developer/js/tests/test-compile-model-with-pseudoclosure.ts
index baba6059c9..391cbbae37 100644
--- a/developer/js/tests/test-compile-model-with-pseudoclosure.ts
+++ b/developer/js/tests/test-compile-model-with-pseudoclosure.ts
@@ -2,12 +2,12 @@ import LexicalModelCompiler from '../dist/lexical-model-compiler/lexical-model-c
import {assert} from 'chai';
import 'mocha';
-import path = require('path');
import { compileModelSourceCode } from './helpers';
+import { makePathToFixture } from './helpers';
describe('LexicalModelCompiler - pseudoclosure compilation + use', function () {
const MODEL_ID = 'example.qaa.trivial';
- const PATH = path.join(__dirname, 'fixtures', MODEL_ID);
+ const PATH = makePathToFixture(MODEL_ID);
describe('specifying custom methods: applyCasing and searchTermToKey', function () {
let casingWithPrependedSymbols: CasingFunction = function(casingName: CasingForm, text: string, defaultApplyCasing: CasingFunction) {
diff --git a/developer/js/tests/test-join-word-breaker.ts b/developer/js/tests/test-join-word-breaker.ts
index c46c4a2d6a..a999c8a93c 100644
--- a/developer/js/tests/test-join-word-breaker.ts
+++ b/developer/js/tests/test-join-word-breaker.ts
@@ -1,6 +1,6 @@
var assert = require('chai').assert;
-const defaultWordBreaker = require('@keymanapp/models-wordbreakers').wordBreakers['default'];
+const defaultWordBreaker = require('../../../common/models/wordbreakers/build').wordBreakers['default'];
import {decorateWithJoin} from '../dist/lexical-model-compiler/join-word-breaker-decorator';
diff --git a/developer/js/tests/test-override-script-defaults.ts b/developer/js/tests/test-override-script-defaults.ts
index 42d58a064b..7f70eed8a5 100644
--- a/developer/js/tests/test-override-script-defaults.ts
+++ b/developer/js/tests/test-override-script-defaults.ts
@@ -1,6 +1,6 @@
var assert = require('chai').assert;
-const defaultWordBreaker = require('@keymanapp/models-wordbreakers').wordBreakers['default'];
+const defaultWordBreaker = require('../../../common/models/wordbreakers/build').wordBreakers['default'];
import {decorateWithScriptOverrides} from '../dist/lexical-model-compiler/script-overrides-decorator';
const THIN_SPACE = "\u2009";
diff --git a/developer/js/tests/test-punctuation.ts b/developer/js/tests/test-punctuation.ts
index 2c8fa9dec8..925a01bd8e 100644
--- a/developer/js/tests/test-punctuation.ts
+++ b/developer/js/tests/test-punctuation.ts
@@ -2,14 +2,14 @@ import LexicalModelCompiler from '../dist/lexical-model-compiler/lexical-model-c
import {assert} from 'chai';
import 'mocha';
-import path = require('path');
import { compileModelSourceCode } from './helpers';
+import { makePathToFixture } from './helpers';
describe('LexicalModelCompiler', function () {
describe('specifying punctuation', function () {
const MODEL_ID = 'example.qaa.trivial';
- const PATH = path.join(__dirname, 'fixtures', MODEL_ID)
+ const PATH = makePathToFixture(MODEL_ID);
it('should compile punctuation into the generated code', function () {
let compiler = new LexicalModelCompiler;
diff --git a/developer/js/tests/tsconfig.json b/developer/js/tests/tsconfig.json
index 655a3fcfe1..9ce358c7f1 100644
--- a/developer/js/tests/tsconfig.json
+++ b/developer/js/tests/tsconfig.json
@@ -1,10 +1,23 @@
{
+ "extends": "../../../tsconfig-base.json",
+
"compilerOptions": {
"module": "commonjs",
+ "moduleResolution": "node",
"noImplicitAny": true,
- "sourceMap": true
+ "sourceMap": true,
+ "rootDir": "./",
+ "outDir": "../dist-tests/"
},
"include": [
- "**/test-*.ts"
- ]
+ "**/test-*.ts",
+ "helpers/index.ts"
+ ],
+ "references": [
+ { "path": "../../../common/web/keyman-version" },
+ { "path": "../../../common/models/types" },
+ { "path": "../../../common/models/templates" },
+ { "path": "../../../common/models/wordbreakers" },
+ { "path": "../"}
+ ]
}
\ No newline at end of file
diff --git a/developer/js/tsconfig.json b/developer/js/tsconfig.json
index ba335fcc7d..741f3c893f 100644
--- a/developer/js/tsconfig.json
+++ b/developer/js/tsconfig.json
@@ -2,11 +2,12 @@
"extends": "../../tsconfig-base.json",
"compilerOptions": {
- //"module": "commonjs",
+ "module": "commonjs",
"target": "es2017",
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist/",
+ "rootDir": "source/",
"declaration": true,
"alwaysStrict": true,
"noImplicitThis": true,