Skip to content

Updated JavaScript kernel with typescript, top-level async/await, es module import, promise resolution #111

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions template/.ts.swcrc

This file was deleted.

2 changes: 1 addition & 1 deletion template/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ RUN R -e "install.packages('IRkernel', repos='https://cloud.r-project.org')"
RUN R -e "IRkernel::installspec(user = FALSE, name = 'r', displayname = 'R')"

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

## TypeScript compiler
Expand Down
26 changes: 0 additions & 26 deletions template/server/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,32 +199,6 @@ async def execute(
+ code
)

if self.language == "typescript":
logger.info("Compiling TypeScript: %s", code)

# call SWC to compile the typescript code
try:
compile_result = subprocess.run("swc --config-file .ts.swcrc --filename index.ts".split(), input=code.encode(), capture_output=True)

if compile_result.returncode != 0:
logger.error("Error during TypeScript compilation: %s", compile_result.stderr.decode())
yield Error(
name="TypeScriptCompilerError",
value=compile_result.stderr.decode(),
traceback="",
)
return

code = compile_result.stdout.decode()
except Exception as e:
logger.error("Error starting SWC process: %s", e)
yield Error(
name="TypeScriptCompilerError",
value=str(e),
traceback="",
)
return

logger.info(code)
request = self._get_execute_request(message_id, code, False)

Expand Down
6 changes: 1 addition & 5 deletions template/test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ COPY ./template/requirements.txt requirements.txt
RUN pip install --no-cache-dir -r requirements.txt && ipython kernel install --name "python3" --user

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

## TypeScript compiler
RUN npm install -g @swc/cli @swc/core
COPY ./template/.ts.swcrc $SERVER_PATH/.ts.swcrc

# Deno Kernel
COPY --from=denoland/deno:bin-2.0.4 /deno /usr/bin/deno
RUN chmod +x /usr/bin/deno
Expand Down
Loading