Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@swc-node/register

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swc-node/register - npm Package Compare versions

Comparing version 0.2.6 to 0.3.1

10

CHANGELOG.md

@@ -6,2 +6,12 @@ # Change Log

## [0.3.1](https://github.com/Brooooooklyn/swc-node/compare/@swc-node/register@0.3.0...@swc-node/register@0.3.1) (2020-08-20)
**Note:** Version bump only for package @swc-node/register
## [0.3.0](https://github.com/Brooooooklyn/swc-node/compare/@swc-node/register@0.2.6...@swc-node/register@0.3.0) (2020-08-20)
### BREAKING CHANGE
- **register:** respect tsconfig.json in SWC_NODE_PROJECT
## [0.2.6](https://github.com/Brooooooklyn/swc-node/compare/@swc-node/register@0.2.5...@swc-node/register@0.2.6) (2020-08-18)

@@ -8,0 +18,0 @@

4

index.d.ts

@@ -1,1 +0,3 @@

export function register(options: import('@swc-node/core').Options & { fallbackToTs: (path: string) => boolean }): void
export function register(
options: import('typescript').CompilerOptions & { fallbackToTs: (path: string) => boolean },
): void

@@ -1,74 +0,3 @@

const { transformSync } = require('@swc-node/core')
const { SourcemapMap, installSourceMapSupport } = require('@swc-node/sourcemap-support')
const { addHook } = require('pirates')
const ts = require('typescript')
const { register } = require('./register')
const DEFAULT_EXTENSIONS = Object.freeze(['.js', '.jsx', '.es6', '.es', '.mjs', '.ts', '.tsx', '.d.ts'])
function toTsTarget(target) {
switch (target) {
case 'es3':
return ts.ScriptTarget.ES3
case 'es5':
return ts.ScriptTarget.ES5
case 'es2015':
return ts.ScriptTarget.ES2015
case 'es2016':
return ts.ScriptTarget.ES2016
case 'es2017':
return ts.ScriptTarget.ES2017
case 'es2018':
return ts.ScriptTarget.ES2018
case 'es2019':
return ts.ScriptTarget.ES2019
case 'es2020':
return ts.ScriptTarget.ES2020
}
}
function toModule(moduleKind) {
switch (moduleKind) {
case 'commonjs':
return ts.ModuleKind.CommonJS
case 'umd':
return ts.ModuleKind.UMD
case 'amd':
return ts.ModuleKind.AMD
case 'es6':
return ts.ModuleKind.ES2015
}
}
function compile(sourcecode, filename, options) {
if (options && typeof options.fallbackToTs === 'function' && options.fallbackToTs(filename)) {
const ts = require('typescript')
const { outputText, sourceMapText } = ts.transpileModule(sourcecode, {
fileName: filename,
compilerOptions: {
jsx: filename.endsWith('.tsx') || filename.endsWith('.jsx') ? ts.JsxEmit.React : ts.JsxEmit.None,
experimentalDecorators: Boolean(options.experimentalDecorators),
emitDecoratorMetadata: Boolean(options.emitDecoratorMetadata),
module: toModule(options.module || 'commonjs'),
moduleResolution: ts.ModuleResolutionKind.NodeJs,
sourceMap: options.sourcemap === false,
target: toTsTarget(options.target || 'es2018'),
esModuleInterop: true,
},
})
if (sourceMapText) {
SourcemapMap.set(filename, sourceMapText)
}
return outputText
} else {
const { code, map } = transformSync(sourcecode, filename, options)
SourcemapMap.set(filename, map)
return code
}
}
module.exports.register = function register(options = {}) {
installSourceMapSupport()
addHook((code, filename) => compile(code, filename, options), {
exts: DEFAULT_EXTENSIONS,
})
}
register()
{
"name": "@swc-node/register",
"version": "0.2.6",
"version": "0.3.1",
"description": "SWC node register",

@@ -41,7 +41,8 @@ "keywords": [

"dependencies": {
"@swc-node/core": "^0.2.6",
"@swc-node/core": "^0.2.8",
"@swc-node/sourcemap-support": "^0.1.7",
"debug": "^4.1.1",
"pirates": "^4.0.1"
},
"gitHead": "50a591f13c939fd5084cb7fa337de73db240e0c0"
"gitHead": "9406e55e868ed1f8dd9a9a516e875e1150444c71"
}
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