Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
buildless-jsx
Advanced tools
Converts the JSX in a Colab notebook cell into browser-compatible JavaScript.
Now you can use a framework like React or Preact in your Colab notebook. Just add Buildless JSX to the bottom of the cell!
Paste this cell into your notebook:
%%html
<script type = "importmap">
{
"imports": {
"preact": "https://esm.sh/*preact@10.7.1"
}
}
</script>
<script>window.onerror = () => true // silence initial JSX parse error</script>
<script type = "module">
window.onerror = undefined;
import {
createElement,
render,
} from 'preact';
const root = document.getElementById('output-body');
render(
<div>
This <div /> was rendered with JSX!
</div>,
root
);
</script>
<script type = "module" src = "https://esm.sh/buildless-jsx"></script>
Buildless JSX scans all the <script>
tags in the cell for JSX markers </
and
/>
. If it finds one, it converts all the JSX in that cell to use the factory
createElement
.
It's the same philosophy as @babel/standalone
, but it works in a notebook with
zero configuration. We use it in Colab, but it should work in any cell that
renders HTML, e.g Jupyter/IPython. Buildless JSX currently uses tsc
for
transpilation.
Buildless JSX is focused on making JSX usable in a notebook. It doesn't watch
the DOM for new <script>
tags. It doesn't expose hooks to configure or swap
out the transpilation engine. It doesn't let you change the name of the JSX
factory.
Because it must live in every cell, the import statement is whittled down to a single line.
Colab only provides JavaScript syntax highlighting when type
is set to a
recognized value like module
. However, this means that the browser will also
try to excute these tags, before Buildless JSX has had a chance to process them.
Luckily, the JSX markers </
and />
are not valid JavaScript. The browser
cannot parse them, so we don't need to worry about the code being run twice.
However, the browser will throw a parse error when it encounters a <script>
tag with unprocessed JSX.
We can suppress this error with a bit of cleverness. Before your JSX
<script>
tag, add this line:
<script>window.onerror = () => true // silence initial JSX parse error</script>
Then at the beginning of your JSX <script>
tag, add this one:
window.onerror = undefined;
This will prevent errors from being written to the console while the invalid JavaScript is in the DOM. As soon a Buildless JSX converts the tag to valid JavaScript, the second line will run, and the global error handler will be re-enabled.
This is not an officially supported Google product. While we do use it internally, open-source support is provided on a best-effort basis.
FAQs
Converts the JSX in a Colab notebook cell into browser-compatible JavaScript.
The npm package buildless-jsx receives a total of 0 weekly downloads. As such, buildless-jsx popularity was classified as not popular.
We found that buildless-jsx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.