mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 05:23:35 +00:00
typescript: Register ts-node to run TS modules in frontend tests.
This commit is contained in:
@@ -1,3 +1,13 @@
|
||||
require('ts-node').register({
|
||||
project: 'static/ts/tsconfig.json',
|
||||
compilerOptions: {
|
||||
typeRoots: ["node_modules/@types", "../../static/ts/js_typings"],
|
||||
// We don't have webpack to handle es6 modules here so directly
|
||||
// transpile to CommonJS format.
|
||||
module: "commonjs",
|
||||
},
|
||||
});
|
||||
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
|
||||
@@ -20,12 +20,19 @@ exports.patch_builtin = function (name, val) {
|
||||
};
|
||||
|
||||
exports.zrequire = function (name, fn) {
|
||||
var path;
|
||||
if (fn === undefined) {
|
||||
fn = 'js/' + name;
|
||||
try {
|
||||
path = require.resolve('js/' + name);
|
||||
} catch (_e /* MODULE_NOT_FOUND */) {
|
||||
path = require.resolve('ts/' + name);
|
||||
}
|
||||
} else {
|
||||
path = require.resolve(fn);
|
||||
}
|
||||
delete require.cache[require.resolve(fn)];
|
||||
var obj = require(fn);
|
||||
requires.push(fn);
|
||||
delete require.cache[path];
|
||||
var obj = require(path);
|
||||
requires.push(path);
|
||||
set_global(name, obj);
|
||||
return obj;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user