- Upgrade
glob
to fix a security vulnerability in theinflight
package. (#822) (Patrick Nappa)- Note that the
sucrase
CLI no longer works in Node.js versions before 14.7.- If you use the
sucrase
CLI, you should pin to Sucrase 3.34.0 until you're able to upgrade Node.js to a supported version. Note that all Node.js versions before 18 are end-of-life. - If you don't use the
sucrase
CLI, you may need to silence errors related to package.jsonengines
, e.g.yarn --ignore-engines
.
- If you use the
- This change is being released in a semver-minor release since it fixes a security vulnerability and the breaking change impact is expected to be small. See this PR comment for a rationale on the release strategy.
- Note that the
- Add CLI options for all remaining Sucrase options, e.g.
--disable-es-transforms
fordisableESTransforms
. (<<-ArS, Alan Pierce) (#670, #812) - Add
SUCRASE_OPTIONS
environment variable for configuringsucrase/register
,sucrase-node
, and any programmatic require hook usages. The value must be a valid JSON object of Sucrase options that will be merged with the usual options. (#813)
- Add an option
keepUnusedImports
that disables all automatic import/export elision, equivalent to the TypeScript optionverbatimModuleSyntax
. (#811, #615) (Kotaro Chikuba, Alan Pierce) - Add support for the
await using
proposal and the updated import attributes proposal. Both are preserved in the output code, not transformed. (#798) - Fix some issues with TypeScript automatic export elision in
export {...} from
statements. (#806)- Type names from the current file are no longer removed.
- When all exports are type exports, the entire statement is now removed.
- Fix bug where
fn(x < y, x >= y)
was incorrectly parsed as type arguments. (#798) - Fix a few bugs in
enableLegacyBabel5ModuleInterop
: properly handleas default
, and properly ignore type exports. (#804, #807) (三咲智子 Kevin Deng, Alan Pierce) - Fix bug where parameters inside function types could be misinterpreted as declarations and result in imports being incorrectly marked as unused. (#809)
- Fix bug where
import {}
andexport {}
statements were removed with the TypeScript transform disabled. (#810) - Make the transform behavior more forgiving when code accidentally has a return type annotation on a constructor. (#800)
- Improve source map quality by adding column information. This fixes several
source map use cases, such as Jest inline snapshots, source map composition,
and some debugger features. (#759) (Emily Marigold Klassen)
- Unfortunately, this change comes at some performance cost. Previously, the slowdown from enabling source maps was about 10%, and now it is about 30%. In most cases, the more detailed source maps are probably still preferable, so for configuration simplicity, there is currently no option to switch back to source maps without column information. If you would like to still use the faster but less accurate implementation, feel free to file an issue to request a new config option, or create the source map yourself in wrapper code by copying the original simple implementation.
- Add option to recognize and preserve JSX syntax. (#788)
- Fix default export interop behavior when using transpiled dynamic
import()
to import a plain CJS module. For example, iffoo.js
hasmodule.exports = 1;
, thenawait import('foo.js')
will now evaluate to{default: 1}
rather than just1
. Named exports behave the same as before. This change matches the behavior of Node.js and other transpilers, so it is considered a bug fix rather than breaking. If you relied on the old behavior, feel free to file an issue and it may be possible to roll back until the next semver-major release. (#789, #790)
- Add support for new syntax in TypeScript 5.0:
- Implement parsing for several ES proposals. These are preserved in the output code, not transformed.
- Fix parsing of
<<
within a type. (#769)
- Add support for the TypeScript 4.9
satisfies
operator. (#766)
- Add ts-node transpiler plugin, available as
sucrase/ts-node-plugin
. This makes it possible to use Sucrase with all ts-node features such as an ESM loader, a REPL, and configuration via tsconfig.json. (#729)
- Add support for
assert {type: 'json'}
in import statements. (#746)
- Add support for the JSX automatic runtime, also known as the
React 17 transform.
It can be enabled using
jsxRuntime: true
and configured using theproduction
andjsxImportSource
configs. (#738, #739, #742, #740)
- Add two new options to more closely match the
module: nodenext
option from TypeScript 4.7:- When using the
imports
transform, the new flagpreserveDynamicImport
will leave dynamicimport()
calls alone rather than compiling them to promise-wrappedrequire
. This makes it possible to load ESM modules from CommonJS. (#727) - When not using the
imports
transform, the new flaginjectCreateRequireForImportRequire
will compileimport foo = require("foo");
to usecreateRequire
so that can work in a Node ES module. (#728)
- When using the
- When
disableESTransforms
is enabled, removeabstract
fields in the same way thatdeclare
fields are removed. This matches TypeScript's behavior. (#732)
- Add support for all new syntax in TypeScript 4.7: (#719)
- Instantiation expressions:
const NumberSet = Set<number>;
extends
oninfer
:T extends [infer S extends string, ...unknown[]] ? S : never;
- Variance annotations:
type Getter<out T> = () => T;
- Instantiation expressions:
- Add parsing support for the
accessor
keyword in ES decorators. (#716) - Fix invalid ESM output that sometimes happened when eliding TS star imports. (#723)
- Fix lots of parser edge case bugs. Examples of code that confused the parser before but now works:
- Fix some edge cases with JSX entity transformation. (#717)
- Add support for TS 4.5 import/export type modifiers. (#713)
- Fix parsing bug that failed on scientific notation with dot access. (#711)
- Add support for Flow enums. (#708, #709)
- Fix some parser bugs when detecting arrow functions. (#673)
- Allow re-export after star export of same name. (#698) (Cameron Pitt)
- Restructure package directory layout to better support ESM. (#684) (Neo Nie)
- Allow the names
true
,false
, andnull
as TS enum keys. (#656, #657) (pushkine, Alan Pierce) - Properly handle TS definite assignment assertions for private fields and when disabling the class transform. (#658)
- Fix ASI issue that broke function declarations immediately following a default export. (#648) (Ben Lambert)
- Fix transformation of anonymous "export default" classes. (#614) (Matthieu Gicquel)
- Handle shadowed globals when they are JSX names. (#642) (Matthieu Gicquel)
- Various small bug fixes and upcoming JS feature support in the parser. (#632, #635, #637)
- Add support for TypeScript 4.2 abstract constructor signatures. (#635)
- Add support for TypeScript 4.3 override, static index signatures, and get/set type members. (#636) (Lucas Garron, Alan Pierce)
- Add support for Flow indexed access types and optional indexed access types. (#636, #637)
- Properly handle imports like
import {default as myFunc} from './myFunc';
when importing from files that are not ES modules. (#619) (Patrik Oldsberg) - Fix bug where other transforms were not being applied to enum value
expressions, so enum declarations like
A = EnumInOtherFile.A
didn't work. (#621)
- Fix regression causing incomplete nullish coalescing and optional chaining in some cases. (#610)
- Add
jest
transform analogous tobabel-plugin-jest-hoist
. (#540) (Patrik Oldsberg) - When calling a
register
function oraddHook
, return a function that reverts the hook. (#604) (Anthony Fu)
- Fix bug where TS method overloads in a class would cause later class fields to not be handled properly. (#593)
- Fix incorrect export removal when exporting a variable defined using a destructure declaration. (#564)
- Add support for new type syntax in TypeScript 4.1: template interpolations in
string literal types and
as
to remap keys in mapped types. Also add parsing for static blocks and pass them through in the output. (#567) - Allow passing
pirates
optionsmatcher
andignoreNodeModules
when directly callingregisterJS
and related functions. (#571, #573) (Gordon Leigh) - Properly emit private class field declarations in the output code so that private fields can be used when they're supported by the target JS engine. (#574)
- Fix parse error when a method or field has the name
declare
. (#575)
- Add support for TypeScript 4.0 type syntax: labeled tuples, catch clause
unknown
. (#556) (Patrik Oldsberg)
- Add support for
declare
class fields in TypeScript. (#537)
- Add support for
export type {T} from './T';
type-only export syntax. (#533) (Patrik Oldsberg)
- Add support for TypeScript 3.8 type-only imports and exports. (#523, #532)
- Add a
--production
flag to the CLI. (#529) (Matthew Phillips) - Fix crash when using
+
or-
in constructor parameter defaults. (#531)
- Properly escape file paths in the react-hot-loader transform. (#512) (Jan Zípek)
- Fix nullish coalescing when the RHS is an object literal. (#516)
- Support reading CLI configuration from tsconfig.json. (#509, #519) (Jake Verbaten)
- Fix crash when parsing
asserts b
TypeScript return signatures. (#504)
- Add support for TypeScript assertion signature syntax, other parser improvements. (#485, #487)
- Implement optional chaining and nullish coalescing. (#488, #490, #492, #496, #497, #498, tech plan)
- Add runtime validation for options. (#468)
- Allow
.tsx
and.jsx
options when runningsucrase
from the command line. (#448) (Ricardo Tomasi, Alexander Mextner) - Fix bug where generator markers in methods were removed. (#463) (Bjørn Tore Håvie)
- Fix parsing of
a<b>c
in TypeScript. (#438) - Add support for new TypeScript 3.4 syntax, other parser improvements. (#439, #440)
- Elide TS
import =
statements that are only used as a type. (#441) - Properly handle async arrow functions with multiline type parameters. (#443)
- Fix bug where
/*/
was being parsed incorrectly. (#430) - Properly parse and compile JSX spread children. (#431)
- Implement TypeScript export elision for exported types. (#433)
- Fix Flow bug where
implements
caused the class name to be incorrectly recognized. (#409) - Correctly handle
!:
in TS variable declarations. (#410) - Move more import code into helper functions in prep for some upcoming changes.
- Fix bug where some JSX component names were incorrectly turned into strings. (#425) (Yang Zhang)
- Fix bug when processing a declaration that looks like an export assignment. (#402)
- Fix TS import elision for JSX fragments and custom pragmas. (#403)
- Treat reserved words as invalid identifiers when handling enums. (#405)
- Avoid false positive when detecting if a class has a superclass. (#399)
- Fix syntax error on arrow functions with multiline return types. (#393)
- Fix crash on optional arrow function params without type annotations. (#389)
- Usability bug fixes for website. (#390)
- Fix react-hot-loader transform syntax error with some export styles. (#384)
- Fix website to properly show react-hot-loader Babel transform output. (#386)
- Add a react-hot-loader transform. (#376)
- Add support for dynamic
import()
syntax in TS types. (#380) - Many improvements to the website, including faster initial pageloads.
- Small performance improvements.
- Fix infinite loop when a file ends with a short identifier (#363)
- Small perf improvements.
- Various simplifications in prep for compiling the project with AssemblyScript.
- Performance improvements, varying from 10% to 70% better performance depending on use case.
- Fix infinite loop in flow
declare module
parsing (#359)
- Fix crash on empty export expressions (#338)
- Fix crash on TypeScript
declare global
(#339) - Fix crash when using overloaded constructors in TypeScript (#340)
- Fix TypeScript import elision when imported names are shadowed by variables (#342)
- Fix import name transform to work in code without semicolons (#337) (Alec Larson)
- Fix perf regression in TypeScript parsing (#327)
- Fix broken line numbers in syntax errors, improve parser backtracking performance (#331)
- Add Parser features and bugfixes from the Babel parser, including TypeScript 3.0 support (#333)
- Add CLI support for jsx pragmas (#321) (Josiah Savary)
- Allow super.method() calls in constructor (#324) (Erik Arvidsson)
- Change class field implementation to use initializer methods (#313)
- Update TypeScript and Flow support to include new language features recently supported by Babel. (#314, #315, #316)
- Properly handle function name inference in named exports (#317)
- Implement destructuring in export declarations (#305)
- Properly handle function name inference in named exports (#308)
- Quote shorthand prop keys that contain a hyphen (#292) (Kevin Gao)
- Fix infinite loop on incomplete JSX. (#296)
- Add a --out-extension option to the CLI. (#282)
- Add a -q/--quiet option in the CLI and use it in the build script. (#284)
- Don't emit semicolons in class bodies. (#285)
- Fix ugly emitted comments when removing code between tokens. (#286)
- Allow TS type parameters on object member methods. (#276)
- Simplify identity source map generator. (#265)
- Fix crash on destructured params in arrow function types. (#278)
- Remove @flow directives from comments when the flow transform is enabled. (#279)
- Fix crash when using JSX elements as props. (#268) (Erik Arvidsson)
- Fix incorrect compilation of TypeScript optional class properties with an initializer. (#264)
- Fix crash on class fields that don't end in a semicolon. (#271)
- Allow trailing commas after rest elements. (#272)
- Don't crash on class bodies with an index signature. (#273)
- Allow member expression identifiers when determining React displayName. (#274)
- Add production option and use it for JSX. (#270) (Erik Arvidsson)
- Fix off-by-one error in parsing JSX fragments. (#275)
- Fix crash in
getVersion
.
transform
now returns an object (#244). You now should writetransform(...).code
instead of justtransform(...)
.code
is the only property for now, but this allows Sucrase to return source maps and possibly other values.- The package's
dist
folder has been restructured, so direct internal module imports may break.
- Overhaul build system to use Sucrase for everything (#243)
- Omit import helpers when unused (#237) (Alec Larson)
- Fix files accidentally included in final package (#233)
- Various refactors and performance improvements.
- Add support for JSX fragment syntax.
- Add support for custom JSX pragmas rather than defaulting to
React.createElement
andReact.Fragment
.