diff --git a/.changeset/dull-flies-bow.md b/.changeset/dull-flies-bow.md new file mode 100644 index 00000000..28c24a35 --- /dev/null +++ b/.changeset/dull-flies-bow.md @@ -0,0 +1,5 @@ +--- +'@e2b/code-interpreter-template': patch +--- + +added swc compiler for TypeScript diff --git a/template/.ts.swcrc b/template/.ts.swcrc new file mode 100644 index 00000000..da515cd2 --- /dev/null +++ b/template/.ts.swcrc @@ -0,0 +1,15 @@ +{ + "$schema": "https://swc.rs/schema.json", + "jsc": { + "parser": { + "syntax": "typescript" + } + }, + "module": { + "type": "commonjs" + }, + "env": { + "targets": "node 20" + }, + "isModule": false +} \ No newline at end of file diff --git a/template/Dockerfile b/template/Dockerfile index b023150d..199a5cb0 100644 --- a/template/Dockerfile +++ b/template/Dockerfile @@ -1,7 +1,11 @@ FROM python:3.10.14 RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \ - build-essential curl git util-linux jq sudo nodejs npm fonts-noto-cjk + build-essential curl git util-linux jq sudo fonts-noto-cjk + +# Install Node.js 20.x from NodeSource +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ + apt-get install -y nodejs ENV PIP_DEFAULT_TIMEOUT=100 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ @@ -24,10 +28,13 @@ 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 node-gyp RUN npm install -g --unsafe-perm ijavascript RUN ijsinstall --install=global +## TypeScript compiler +RUN npm install -g @swc/cli @swc/core +COPY .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 diff --git a/template/test.Dockerfile b/template/test.Dockerfile index f3647911..f9302081 100644 --- a/template/test.Dockerfile +++ b/template/test.Dockerfile @@ -5,7 +5,11 @@ COPY --from=eclipse-temurin:11-jdk $JAVA_HOME $JAVA_HOME ENV PATH="${JAVA_HOME}/bin:${PATH}" RUN DEBIAN_FRONTEND=noninteractive apt-get update && apt-get install -y --no-install-recommends \ - build-essential curl git util-linux jq sudo nodejs npm fonts-noto-cjk + build-essential curl git util-linux jq sudo fonts-noto-cjk + +# Install Node.js 20.x from NodeSource +RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \ + apt-get install -y nodejs ENV PIP_DEFAULT_TIMEOUT=100 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ @@ -19,10 +23,13 @@ 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 node-gyp RUN npm install -g --unsafe-perm ijavascript 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