Socket
Socket
Sign inDemoInstall

sucrase

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sucrase - npm Package Compare versions

Comparing version 3.33.0 to 3.34.0

38

dist/cli.js

@@ -36,5 +36,26 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }/* eslint-disable no-console */

.option("--exclude-dirs <paths>", "Names of directories that should not be traversed.")
.option("-q, --quiet", "Don't print the names of converted files.")
.option("-t, --transforms <transforms>", "Comma-separated list of transforms to run.")
.option("-q, --quiet", "Don't print the names of converted files.")
.option("--disable-es-transforms", "Opt out of all ES syntax transforms.")
.option("--jsx-runtime <string>", "Transformation mode for the JSX transform.")
.option("--production", "Disable debugging information from JSX in output.")
.option(
"--jsx-import-source <string>",
"Automatic JSX transform import path prefix, defaults to `React.Fragment`.",
)
.option(
"--jsx-pragma <string>",
"Classic JSX transform element creation function, defaults to `React.createElement`.",
)
.option(
"--jsx-fragment-pragma <string>",
"Classic JSX transform fragment component, defaults to `React.Fragment`.",
)
.option("--keep-unused-imports", "Disable automatic removal of type-only imports/exports.")
.option("--preserve-dynamic-import", "Don't transpile dynamic import() to require.")
.option(
"--inject-create-require-for-import-require",
"Use `createRequire` when transpiling TS `import = require` to ESM.",
)
.option(
"--enable-legacy-typescript-module-interop",

@@ -44,5 +65,2 @@ "Use default TypeScript ESM/CJS interop strategy.",

.option("--enable-legacy-babel5-module-interop", "Use Babel 5 ESM/CJS interop strategy.")
.option("--jsx-pragma <string>", "Element creation function, defaults to `React.createElement`")
.option("--jsx-fragment-pragma <string>", "Fragment component, defaults to `React.Fragment`")
.option("--production", "Disable debugging information from JSX in output.")
.parse(process.argv);

@@ -89,7 +107,13 @@

transforms: _commander2.default.transforms ? _commander2.default.transforms.split(",") : [],
disableESTransforms: _commander2.default.disableEsTransforms,
jsxRuntime: _commander2.default.jsxRuntime,
production: _commander2.default.production,
jsxImportSource: _commander2.default.jsxImportSource,
jsxPragma: _commander2.default.jsxPragma || "React.createElement",
jsxFragmentPragma: _commander2.default.jsxFragmentPragma || "React.Fragment",
keepUnusedImports: _commander2.default.keepUnusedImports,
preserveDynamicImport: _commander2.default.preserveDynamicImport,
injectCreateRequireForImportRequire: _commander2.default.injectCreateRequireForImportRequire,
enableLegacyTypeScriptModuleInterop: _commander2.default.enableLegacyTypescriptModuleInterop,
enableLegacyBabel5ModuleInterop: _commander2.default.enableLegacyBabel5ModuleInterop,
jsxPragma: _commander2.default.jsxPragma || "React.createElement",
jsxFragmentPragma: _commander2.default.jsxFragmentPragma || "React.Fragment",
production: _commander2.default.production,
},

@@ -96,0 +120,0 @@ };

@@ -36,5 +36,26 @@ /* eslint-disable no-console */

.option("--exclude-dirs <paths>", "Names of directories that should not be traversed.")
.option("-q, --quiet", "Don't print the names of converted files.")
.option("-t, --transforms <transforms>", "Comma-separated list of transforms to run.")
.option("-q, --quiet", "Don't print the names of converted files.")
.option("--disable-es-transforms", "Opt out of all ES syntax transforms.")
.option("--jsx-runtime <string>", "Transformation mode for the JSX transform.")
.option("--production", "Disable debugging information from JSX in output.")
.option(
"--jsx-import-source <string>",
"Automatic JSX transform import path prefix, defaults to `React.Fragment`.",
)
.option(
"--jsx-pragma <string>",
"Classic JSX transform element creation function, defaults to `React.createElement`.",
)
.option(
"--jsx-fragment-pragma <string>",
"Classic JSX transform fragment component, defaults to `React.Fragment`.",
)
.option("--keep-unused-imports", "Disable automatic removal of type-only imports/exports.")
.option("--preserve-dynamic-import", "Don't transpile dynamic import() to require.")
.option(
"--inject-create-require-for-import-require",
"Use `createRequire` when transpiling TS `import = require` to ESM.",
)
.option(
"--enable-legacy-typescript-module-interop",

@@ -44,5 +65,2 @@ "Use default TypeScript ESM/CJS interop strategy.",

.option("--enable-legacy-babel5-module-interop", "Use Babel 5 ESM/CJS interop strategy.")
.option("--jsx-pragma <string>", "Element creation function, defaults to `React.createElement`")
.option("--jsx-fragment-pragma <string>", "Fragment component, defaults to `React.Fragment`")
.option("--production", "Disable debugging information from JSX in output.")
.parse(process.argv);

@@ -89,7 +107,13 @@

transforms: commander.transforms ? commander.transforms.split(",") : [],
disableESTransforms: commander.disableEsTransforms,
jsxRuntime: commander.jsxRuntime,
production: commander.production,
jsxImportSource: commander.jsxImportSource,
jsxPragma: commander.jsxPragma || "React.createElement",
jsxFragmentPragma: commander.jsxFragmentPragma || "React.Fragment",
keepUnusedImports: commander.keepUnusedImports,
preserveDynamicImport: commander.preserveDynamicImport,
injectCreateRequireForImportRequire: commander.injectCreateRequireForImportRequire,
enableLegacyTypeScriptModuleInterop: commander.enableLegacyTypescriptModuleInterop,
enableLegacyBabel5ModuleInterop: commander.enableLegacyBabel5ModuleInterop,
jsxPragma: commander.jsxPragma || "React.createElement",
jsxFragmentPragma: commander.jsxFragmentPragma || "React.Fragment",
production: commander.production,
},

@@ -96,0 +120,0 @@ };

2

dist/esm/index.js

@@ -32,3 +32,3 @@ import CJSImportProcessor from "./CJSImportProcessor";

/* istanbul ignore next */
return "3.33.0";
return "3.34.0";
}

@@ -35,0 +35,0 @@

@@ -14,9 +14,14 @@ import * as pirates from "pirates";

extension,
options,
sucraseOptions,
hookOptions,
) {
let mergedSucraseOptions = sucraseOptions;
const sucraseOptionsEnvJSON = process.env.SUCRASE_OPTIONS;
if (sucraseOptionsEnvJSON) {
mergedSucraseOptions = {...mergedSucraseOptions, ...JSON.parse(sucraseOptionsEnvJSON)};
}
return pirates.addHook(
(code, filePath) => {
const {code: transformedCode, sourceMap} = transform(code, {
...options,
...mergedSucraseOptions,
sourceMapOptions: {compiledFilename: filePath},

@@ -23,0 +28,0 @@ filePath,

@@ -32,3 +32,3 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _CJSImportProcessor = require('./CJSImportProcessor'); var _CJSImportProcessor2 = _interopRequireDefault(_CJSImportProcessor);

/* istanbul ignore next */
return "3.33.0";
return "3.34.0";
} exports.getVersion = getVersion;

@@ -35,0 +35,0 @@

@@ -14,9 +14,14 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }var _pirates = require('pirates'); var pirates = _interopRequireWildcard(_pirates);

extension,
options,
sucraseOptions,
hookOptions,
) {
let mergedSucraseOptions = sucraseOptions;
const sucraseOptionsEnvJSON = process.env.SUCRASE_OPTIONS;
if (sucraseOptionsEnvJSON) {
mergedSucraseOptions = {...mergedSucraseOptions, ...JSON.parse(sucraseOptionsEnvJSON)};
}
return pirates.addHook(
(code, filePath) => {
const {code: transformedCode, sourceMap} = _index.transform.call(void 0, code, {
...options,
...mergedSucraseOptions,
sourceMapOptions: {compiledFilename: filePath},

@@ -23,0 +28,0 @@ filePath,

@@ -7,3 +7,3 @@ import { type Options } from "./index";

export type RevertFunction = () => void;
export declare function addHook(extension: string, options: Options, hookOptions?: HookOptions): RevertFunction;
export declare function addHook(extension: string, sucraseOptions: Options, hookOptions?: HookOptions): RevertFunction;
export declare function registerJS(hookOptions?: HookOptions): RevertFunction;

@@ -10,0 +10,0 @@ export declare function registerJSX(hookOptions?: HookOptions): RevertFunction;

{
"name": "sucrase",
"version": "3.33.0",
"version": "3.34.0",
"description": "Super-fast alternative to Babel for when you can target modern JS runtimes",

@@ -69,3 +69,3 @@ "author": "Alan Pierce <alangpierce@gmail.com>",

"prettier": "^2.8.8",
"sucrase": "^3.32.0",
"sucrase": "^3.33.0",
"test262-harness": "^10.0.0",

@@ -72,0 +72,0 @@ "ts-interface-builder": "^0.3.3",

@@ -194,2 +194,5 @@ # Sucrase

Options can be passed to the require hook via a `SUCRASE_OPTIONS` environment
variable holding a JSON string of options.
### Compiling a project to JS

@@ -196,0 +199,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc