Skip to content

Commit e9e0903

Browse files
authored
Updated JavaScript kernel with typescript, top-level async/await, es module import, promise resolution (#111)
* e2b ijavascript kernel * removed compiler step * e2b ijavascript * removed ts compiler from dockerfile * removed tests that should no longer be failing * added changeset
1 parent 8f38106 commit e9e0903

File tree

8 files changed

+7
-71
lines changed

8 files changed

+7
-71
lines changed

.changeset/breezy-bananas-lay.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@e2b/code-interpreter-template': patch
3+
---
4+
5+
updated ijavascript kernel in the template

js/tests/defaultKernels.test.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,3 @@ sandboxTest('test ts kernel', async ({ sandbox }) => {
1616
)
1717
expect(output.logs.stdout).toEqual(['Hello World!\n'])
1818
})
19-
20-
sandboxTest('test ts kernel errors', async ({ sandbox }) => {
21-
const output = await sandbox.runCode('import x from "module";', {
22-
language: 'typescript',
23-
})
24-
expect(output.error?.name).toEqual('TypeScriptCompilerError')
25-
})

python/tests/async/test_async_default_kernels.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,3 @@ async def test_ts_kernel(async_sandbox: AsyncSandbox):
1313
"const message: string = 'Hello, World!'; console.log(message);", language="ts"
1414
)
1515
assert execution.logs.stdout == ["Hello, World!\n"]
16-
17-
18-
async def test_ts_kernel_errors(async_sandbox: AsyncSandbox):
19-
execution = await async_sandbox.run_code(
20-
"import x from 'module';", language="ts"
21-
)
22-
assert execution.error is not None
23-
assert execution.error.name == "TypeScriptCompilerError"

python/tests/sync/test_default_kernels.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,3 @@ def test_ts_kernel(sandbox: Sandbox):
2525
execution = sandbox.run_code("const message: string = 'Hello, World!'; console.log(message)", language="ts")
2626
assert execution.logs.stdout == ["Hello, World!\n"]
2727

28-
29-
def test_ts_kernel_errors(sandbox: Sandbox):
30-
execution = sandbox.run_code("import x from 'module';", language="ts")
31-
assert execution.error is not None
32-
assert execution.error.name == "TypeScriptCompilerError"

template/.ts.swcrc

Lines changed: 0 additions & 15 deletions
This file was deleted.

template/Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,9 @@ RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org')"
2828
RUN R -e "IRkernel::installspec(user = FALSE, name = 'r', displayname = 'R')"
2929

3030
# Javascript Kernel
31-
RUN npm install -g --unsafe-perm ijavascript
31+
RUN npm install -g --unsafe-perm git+https://github.com/e2b-dev/ijavascript.git
3232
RUN ijsinstall --install=global
3333

34-
## TypeScript compiler
35-
RUN npm install -g @swc/cli @swc/core
36-
COPY .ts.swcrc $SERVER_PATH/.ts.swcrc
37-
3834
# Deno Kernel
3935
COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno
4036
RUN chmod +x /usr/bin/deno

template/server/messaging.py

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -199,32 +199,6 @@ async def execute(
199199
+ code
200200
)
201201

202-
if self.language == "typescript":
203-
logger.info("Compiling TypeScript: %s", code)
204-
205-
# call SWC to compile the typescript code
206-
try:
207-
compile_result = subprocess.run("swc --config-file .ts.swcrc --filename index.ts".split(), input=code.encode(), capture_output=True)
208-
209-
if compile_result.returncode != 0:
210-
logger.error("Error during TypeScript compilation: %s", compile_result.stderr.decode())
211-
yield Error(
212-
name="TypeScriptCompilerError",
213-
value=compile_result.stderr.decode(),
214-
traceback="",
215-
)
216-
return
217-
218-
code = compile_result.stdout.decode()
219-
except Exception as e:
220-
logger.error("Error starting SWC process: %s", e)
221-
yield Error(
222-
name="TypeScriptCompilerError",
223-
value=str(e),
224-
traceback="",
225-
)
226-
return
227-
228202
logger.info(code)
229203
request = self._get_execute_request(message_id, code, False)
230204

template/test.Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,9 @@ COPY ./template/requirements.txt requirements.txt
2323
RUN pip install --no-cache-dir -r requirements.txt && ipython kernel install --name "python3" --user
2424

2525
# Javascript Kernel
26-
RUN npm install -g --unsafe-perm ijavascript
26+
RUN npm install -g --unsafe-perm git+https://github.com/e2b-dev/ijavascript.git
2727
RUN ijsinstall --install=global
2828

29-
## TypeScript compiler
30-
RUN npm install -g @swc/cli @swc/core
31-
COPY ./template/.ts.swcrc $SERVER_PATH/.ts.swcrc
32-
3329
# Deno Kernel
3430
COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno
3531
RUN chmod +x /usr/bin/deno

0 commit comments

Comments
 (0)