Skip to content
This repository was archived by the owner on Nov 5, 2025. It is now read-only.

Commit bf590b6

Browse files
authored
feat: improve package installation and deno caching (#786)
1 parent 292d69f commit bf590b6

File tree

5 files changed

+24
-5
lines changed

5 files changed

+24
-5
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jspm_packages
3838
.npm
3939

4040
.deno
41+
.deno-cache
4142

4243
# Optional REPL history
4344
.node_repl_history

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"test:node": "NODE_ENV=test ts-node ./tests/runner.ts",
2020
"test:deno": "cd deno-runtime && deno task test",
2121
"gen-doc": "typedoc",
22-
"postinstall": "cd deno-runtime && deno cache main.ts && deno test --no-check --no-run"
22+
"postinstall": "node scripts/postinstall.js"
2323
},
2424
"repository": {
2525
"type": "git",
@@ -32,10 +32,11 @@
3232
],
3333
"files": [
3434
"client/**",
35-
"server/**",
3635
"definition/**",
36+
"deno-runtime/**",
3737
"lib/**",
38-
"deno-runtime/**"
38+
"scripts/**",
39+
"server/**"
3940
],
4041
"author": {
4142
"name": "Rocket.Chat",

scripts/postinstall.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const childProcess = require('child_process');
2+
const path = require('path');
3+
4+
// Find executable installed by deno-bin
5+
const executablePath = path.join(require.resolve('deno-bin'), '..', 'bin', 'deno');
6+
7+
const rootPath = path.join(__dirname, '..');
8+
const DENO_DIR = path.join(rootPath, '.deno-cache');
9+
10+
childProcess.spawnSync(executablePath, ['cache', 'main.ts'], {
11+
cwd: path.join(rootPath, 'deno-runtime'),
12+
env: {
13+
DENO_DIR,
14+
},
15+
stdio: 'inherit',
16+
});

src/server/runtime/deno/AppsEngineDenoRuntime.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
128128
const denoWrapperPath = getDenoWrapperPath();
129129
// During development, the appsEngineDir is enough to run the deno process
130130
const appsEngineDir = path.dirname(path.join(denoWrapperPath, '..'));
131+
const DENO_DIR = path.join(appsEngineDir, '.deno-cache');
131132
// When running in production, we're likely inside a node_modules which the Deno
132133
// process must be able to read in order to include files that use NPM packages
133134
const parentNodeModulesDir = path.dirname(path.join(appsEngineDir, '..'));
@@ -150,7 +151,7 @@ export class DenoRuntimeSubprocessController extends EventEmitter {
150151
this.appPackage.info.id,
151152
];
152153

153-
this.deno = child_process.spawn(denoExePath, options, { env: null });
154+
this.deno = child_process.spawn(denoExePath, options, { env: { DENO_DIR } });
154155
this.messenger.setReceiver(this.deno);
155156
this.livenessManager.attach(this.deno);
156157

tsconfig-lint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"compilerOptions": {
44
"allowJs": true
55
},
6-
"include": ["./src/**/*", "./tests/**/*", "./gulpfile.js"]
6+
"include": ["./scripts/*", "./src/**/*", "./tests/**/*", "./gulpfile.js"]
77
}

0 commit comments

Comments
 (0)