question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can we run sucrase in the browser like babel-standalone?

See original GitHub issue

For the same reasons babel-standalone exists. Would be nice to be able to run sucrase in browser code.

e.g.

<div id="root"></div>
<script src="https://unpkg.com/.../sucrase.js"></script>
<script type="text/sucrase" src="app.js"></script>

Right now babel-standalone doesn’t support React Fragments (it’s stuck on babel v7 beta 3).

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ClassicOldSongcommented, Nov 30, 2021

It’ll be nice if Sucrase could include a UMD or IIFE version in release. Then we’ll be able to use it directly via importScripts in Service Workers.

I’m writing an on-the-fly build tool using Service Worker, whose goal is to rid of node completely for modern frontend development/production, and I’m finding an alternative to esbuild since it could go out of stack strangely in Safari, but lacking of UMD/IIFE support won’t make me able to create a plugin for Sucrase.

Currently there’s only a CJS version and https://bundle.run/sucrase could do nothing about it.

1reaction
nestarzcommented, Dec 24, 2020

Here an example on how you can setup sucrase to work in the browser using a service worker: https://gist.github.com/nestarz/dcaa70b5ecac5fa7e66103658f7ff0b7

The caveat is that I copied paste the code (from skypack) of sucrase inside the sw.js.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Comparing Babel, Sucrase, and Similar Libraries
Babel compiles all your code down to what your browser can run, while Sucrase focuses on a small portion of what Babel does....
Read more >
Can we run sucrase in the browser like babel-standalone?
For the same reasons babel-standalone exists. Would be nice to be able to run sucrase in browser code. e.g.
Read more >
babel/standalone
babel /standalone provides a standalone build of Babel for use in browsers and other non-Node.js environments.
Read more >
Emscripten vs Sucrase | What are the differences? - StackShare
Sucrase is an alternative to Babel that allows super-fast development builds. Instead of compiling a large range of JS features down to ES5,...
Read more >
Sucrase, a Faster Babel for Modern JS Runtimes - InfoQ
You should think carefully before using Sucrase in production. Sucrase is mostly beneficial in development, and in many cases, Babel or tsc will ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found