@jackctaylor/roblox-ts 3.0.0-projectrefs.0 → 3.0.0-projectrefs.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -196,8 +196,6 @@ module.exports = typescript_1.default.identity({
196
196
  function fixSlashes(fsPath) {
197
197
  return fsPath.replace(/\\/g, "/");
198
198
  }
199
- let initialCompileCompleted = false;
200
- let collecting = false;
201
199
  let filesToAdd = new Set();
202
200
  let filesToChange = new Set();
203
201
  let filesToDelete = new Set();
@@ -342,6 +340,7 @@ module.exports = typescript_1.default.identity({
342
340
  }
343
341
  return allDiagnostics;
344
342
  }
343
+ let initialCompileCompleted = false;
345
344
  function runCompile() {
346
345
  try {
347
346
  if (!initialCompileCompleted) {
@@ -370,16 +369,22 @@ module.exports = typescript_1.default.identity({
370
369
  }
371
370
  }
372
371
  }
372
+ let collecting = false;
373
+ let collectionTimeout;
373
374
  function closeEventCollection() {
374
375
  collecting = false;
376
+ collectionTimeout = undefined;
375
377
  reportEmitResult(runCompile());
376
378
  }
377
379
  function openEventCollection() {
378
380
  if (!collecting) {
379
381
  collecting = true;
380
382
  reportText("File change detected. Starting incremental compilation...");
381
- setTimeout(closeEventCollection, 100);
382
383
  }
384
+ if (collectionTimeout) {
385
+ clearTimeout(collectionTimeout);
386
+ }
387
+ collectionTimeout = setTimeout(closeEventCollection, 100);
383
388
  }
384
389
  function collectAddEvent(fsPath) {
385
390
  filesToAdd.add(fixSlashes(fsPath));
@@ -4,10 +4,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.createTransformerWatcher = createTransformerWatcher;
7
+ const crypto_1 = __importDefault(require("crypto"));
7
8
  const typescript_1 = __importDefault(require("typescript"));
8
9
  function createServiceHost(program) {
9
10
  const rootFileNames = program.getRootFileNames().map(x => x);
10
11
  const files = new Map();
12
+ const hashCache = new Map();
11
13
  rootFileNames.forEach(fileName => {
12
14
  files.set(fileName, 0);
13
15
  });
@@ -33,9 +35,18 @@ function createServiceHost(program) {
33
35
  getProjectReferences: () => program.getProjectReferences(),
34
36
  };
35
37
  function getScriptVersion(fileName) {
36
- var _a;
37
- const version = (_a = files.get(fileName)) === null || _a === void 0 ? void 0 : _a.toString();
38
- return version !== null && version !== void 0 ? version : "0";
38
+ const version = files.get(fileName);
39
+ if (version !== undefined) {
40
+ return version.toString();
41
+ }
42
+ const content = typescript_1.default.sys.readFile(fileName);
43
+ if (!content) {
44
+ hashCache.delete(fileName);
45
+ return "0";
46
+ }
47
+ const hash = crypto_1.default.createHash("sha1").update(content).digest("hex");
48
+ hashCache.set(fileName, hash);
49
+ return hash;
39
50
  }
40
51
  function getScriptSnapshot(fileName) {
41
52
  const content = readFile(fileName);
@@ -170,7 +170,7 @@ class TransformState {
170
170
  });
171
171
  }
172
172
  else {
173
- const sourceOutPath = this.pathTranslator.getOutputPath(sourceFile.fileName);
173
+ const sourceOutPath = this.getPathTranslatorForFile(sourceFile.path).getOutputPath(sourceFile.fileName);
174
174
  const rbxPath = this.rojoResolver.getRbxPathFromFilePath(sourceOutPath);
175
175
  if (!rbxPath) {
176
176
  DiagnosticService_1.DiagnosticService.addDiagnostic(diagnostics_1.errors.noRojoData(sourceFile, path_1.default.relative(this.data.projectPath, sourceOutPath), false));
@@ -150,7 +150,7 @@ function transformSourceFile(state, node) {
150
150
  handleExports(state, node, symbol, statements);
151
151
  const lastStatement = getLastNonCommentStatement(statements.tail);
152
152
  if (!lastStatement || !luau_ast_1.default.isReturnStatement(lastStatement.value)) {
153
- const outputPath = state.pathTranslator.getOutputPath(node.fileName);
153
+ const outputPath = state.getPathTranslatorForFile(node.fileName).getOutputPath(node.fileName);
154
154
  if (state.rojoResolver.getRbxTypeFromFilePath(outputPath) === rojo_resolver_1.RbxType.ModuleScript) {
155
155
  luau_ast_1.default.list.push(statements, luau_ast_1.default.create(luau_ast_1.default.SyntaxKind.ReturnStatement, { expression: luau_ast_1.default.nil() }));
156
156
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackctaylor/roblox-ts",
3
- "version": "3.0.0-projectrefs.0",
3
+ "version": "3.0.0-projectrefs.1",
4
4
  "description": "A TypeScript-to-Luau Compiler for Roblox",
5
5
  "main": "out/CLI/index.js",
6
6
  "repository": {