Sucrase v3.35.1 is a super-fast JavaScript/TypeScript transpiler focused on modern JS runtimes. Unlike Babel or TypeScript, it only compiles non-standard language extensions (JSX, TypeScript, Flow) and ES modules to CommonJS, offering ~20x speed improvement. It ships TypeScript types, requires Node >=16 or 14.17+, and is actively maintained on GitHub. Primarily used for development builds where type checking is handled separately.
npm install sucraseVerified import paths — ran on the pinned version, not inferred.
Read a TypeScript file, remove type annotations, and convert ES modules to CommonJS.
Consider using Node.js --loader or --experimental-loader flags with a custom hook.
Enable TypeScript's `isolatedModules` flag to disallow `const enum`s.
Use `sourceMaps` and `sourceMapUrl` options instead. Upgrade to Node >=14.17.
Use `jsxRuntime: 'automatic'` and add `jsxImportSource` or ensure React is globally available.
Use require('sucrase/register') or check that sucrase is installed as a devDependency.Preprocess decorators with a separate tool like Babel or use a TypeScript transformer.
Run tsc separately or use the `--noEmit` flag for type checking before Sucrase.