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

rollup-plugin-swc3

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rollup-plugin-swc3 - npm Package Compare versions

Comparing version 0.4.2 to 0.5.0

.node-version

16

dist/index.js

@@ -36,3 +36,3 @@ 'use strict';

if (path && data) {
const { importHelpers , esModuleInterop , experimentalDecorators , emitDecoratorMetadata , jsxFactory , jsxFragmentFactory , jsxImportSource , target , baseUrl , paths } = data.compilerOptions || {};
const { importHelpers , esModuleInterop , experimentalDecorators , emitDecoratorMetadata , jsx , jsxFactory , jsxFragmentFactory , jsxImportSource , target , baseUrl , paths } = data.compilerOptions || {};
return {

@@ -43,2 +43,3 @@ importHelpers,

emitDecoratorMetadata,
jsx,
jsxFactory,

@@ -66,5 +67,3 @@ jsxFragmentFactory,

const fileExists = (path)=>{
return fs__default["default"].promises.access(path, fs__default["default"].constants.F_OK).then(()=>true
).catch(()=>false
);
return fs__default["default"].promises.access(path, fs__default["default"].constants.F_OK).then(()=>true).catch(()=>false);
};

@@ -111,2 +110,6 @@ const resolveFile = async (resolved, index = false)=>{

const tsconfigOptions = options.tsconfig === false ? {} : await getOptions(path.dirname(id), options.tsconfig);
// TODO: SWC is about to add "preserve" jsx
// https://github.com/swc-project/swc/pull/5661
// Respect "preserve" after swc adds the support
const useReact17NewTransform = tsconfigOptions.jsx === 'react-jsx' || tsconfigOptions.jsx === 'react-jsxdev';
const swcOptionsFromTsConfig = {

@@ -124,4 +127,7 @@ jsc: {

react: {
runtime: useReact17NewTransform ? 'automatic' : 'classic',
importSource: tsconfigOptions.jsxImportSource,
pragma: tsconfigOptions.jsxFactory,
pragmaFrag: tsconfigOptions.jsxFragmentFactory
pragmaFrag: tsconfigOptions.jsxFragmentFactory,
development: tsconfigOptions.jsx === 'react-jsxdev' ? true : undefined
}

@@ -128,0 +134,0 @@ },

{
"name": "rollup-plugin-swc3",
"version": "0.4.2",
"version": "0.5.0",
"description": "Use SWC with Rollup to transform ESNext and TypeScript code.",

@@ -32,25 +32,25 @@ "main": "dist/index.js",

"joycon": "^3.1.1",
"jsonc-parser": "^3.0.0"
"jsonc-parser": "^3.2.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-json": "^4.1.0",
"@swc/core": "^1.2.165",
"@types/chai": "^4.3.1",
"@types/mocha": "^9.1.0",
"@types/node": "^16.11.27",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"@swc/core": "^1.2.246",
"@types/chai": "^4.3.3",
"@types/mocha": "^9.1.1",
"@types/node": "^18.7.14",
"@typescript-eslint/eslint-plugin": "^5.36.1",
"@typescript-eslint/parser": "^5.36.1",
"chai": "^4.3.6",
"eslint": "^8.13.0",
"eslint-config-sukka": "^1.3.0",
"eslint-import-resolver-typescript": "^2.7.1",
"eslint": "^8.23.0",
"eslint-config-sukka": "^1.4.0",
"eslint-import-resolver-typescript": "^3.5.0",
"eslint-plugin-import": "^2.26.0",
"mocha": "^9.2.2",
"mocha": "^10.0.0",
"rimraf": "^3.0.2",
"rollup": "^2.70.2",
"rollup-plugin-dts": "^4.2.1",
"ts-mocha": "^9.0.2",
"ts-node": "^10.7.0",
"typescript": "^4.4.4"
"rollup": "^2.79.0",
"rollup-plugin-dts": "^4.2.2",
"ts-mocha": "^10.0.0",
"ts-node": "^10.9.1",
"typescript": "^4.8.2"
},

@@ -57,0 +57,0 @@ "peerDependencies": {

@@ -50,2 +50,3 @@ <div align="center">

tsconfig: 'tsconfig.json', // default
// tsconfig: false, // You can also prevent `rollup-plugin-swc` from reading tsconfig.json, see below
// And add your swc configuration here!

@@ -80,6 +81,17 @@ // "filename" will be ignored since it is handled by rollup

- `include` and `exclude` can be `String | RegExp | Array<String | RegExp>`, when supplied it will override default values.
- It uses `importHelpers`, `experimentalDecorators`, `emitDecoratorMetadata`, `jsxFactory`, `jsxFragmentFactory`, `target`, `baseUrl` and `paths` options from your `tsconfig.json` or [`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) as default values if your doesn't provide corresponding swc configuration.
- Currently, `rollup-plugin-swc` won't use `esModuleInterop` from your `tsconfig.json` as swc requires `module.type` configuration when `module.noInterop` is given.
- `rollup-plugin-swc` will read your `tsconfig.json` or [`jsconfig.json`](https://code.visualstudio.com/docs/languages/jsconfig) for default values if your doesn't provide corresponding swc options:
- The configuration your passed to `rollup-plugin-swc` will always have the highest priority (higher than `tsconfig.json`/`jsconfig.json`).
- You can stop `rollup-plugin-swc` from reading `tsconfig.json`/`jsconfig.json` by setting `tsconfig` option to `false`.
- You can provide a custom `tsconfig.json`/`jsconfig.json` file by setting `tsconfig` option to a `string`.
- `jsconfig.json` will be ignored if `tsconfig.json` and `jsconfig.json` both exist.
- `baseUrl` and `paths` will be passed to swc directly. They won't affect how rollup resolve your imports. Please use other plugins to resolve your imports' aliases (e.g., add [rollup-plugin-typescript-paths](https://www.npmjs.com/package/rollup-plugin-typescript-paths) or [rollup-plugin-tsconfig-paths](https://www.npmjs.com/package/rollup-plugin-tsconfig-paths) before `@rollup/plugin-node-resolve`).
- The `extends` of `tsconfig.json`/`jsconfig.json` is not supported.
- `target` will be passed to swc's `jsc.target`.
- `jsxImportSource`, `jsxFactory`, and `jsxFragmentFactory` will be passed to swc's `jsc.transform.react.importSource`, `jsc.transform.react.pragma` and `jsc.transform.react.pragmaFrag`.
- When `jsx` is either `react-jsx` or `react-jsxdev`, swc's `jsc.transform.react.runtime` will be `automatic`, otherwise it will be `classic`.
- Note that `jsx: preserve` will be ignored and swc will always transpile your jsx into javascript code.
- When `jsx` is `react-jsxdev`, swc's `jsc.transform.react.development` will also be enabled.
- `baseUrl` and `paths` will be passed to swc's `jsc.baseUrl` and `jsx.paths` directly. They won't affect how rollup resolve your imports. If you have encounted any issue during bundling, please use other plugins to resolve your imports' aliases (e.g., add [rollup-plugin-typescript-paths](https://www.npmjs.com/package/rollup-plugin-typescript-paths) or [rollup-plugin-tsconfig-paths](https://www.npmjs.com/package/rollup-plugin-tsconfig-paths) before `@rollup/plugin-node-resolve`).
- `importHelpers` will be passed to swc's `jsc.externalHelpers`, so you will have to have `@swc/helpers` avaliable in your project when enabled.
- `experimentalDecorators` and `emitDecoratorMetadata` will be passed to swc's `jsc.parser.decorators` and `jsc.transform.decoratorMetadata`.
- `esModuleInterop` will always be ignored, as swc requires `module.type` to exist when `module.noInterop` is given.

@@ -86,0 +98,0 @@ ### Standalone Minify Plugin

@@ -92,2 +92,7 @@ import type { Plugin } from 'rollup';

// TODO: SWC is about to add "preserve" jsx
// https://github.com/swc-project/swc/pull/5661
// Respect "preserve" after swc adds the support
const useReact17NewTransform = tsconfigOptions.jsx === 'react-jsx' || tsconfigOptions.jsx === 'react-jsxdev';
const swcOptionsFromTsConfig: SwcOptions = {

@@ -105,4 +110,9 @@ jsc: {

react: {
runtime: useReact17NewTransform
? 'automatic'
: 'classic',
importSource: tsconfigOptions.jsxImportSource,
pragma: tsconfigOptions.jsxFactory,
pragmaFrag: tsconfigOptions.jsxFragmentFactory
pragmaFrag: tsconfigOptions.jsxFragmentFactory,
development: tsconfigOptions.jsx === 'react-jsxdev' ? true : undefined
}

@@ -109,0 +119,0 @@ },

@@ -23,2 +23,3 @@ import fs from 'fs';

emitDecoratorMetadata?: boolean,
jsx?: 'preserve' | 'react' | 'react-jsx' | 'react-jsxdev' | 'react-native',
jsxFactory?: string,

@@ -39,2 +40,3 @@ jsxFragmentFactory?: string,

emitDecoratorMetadata,
jsx,
jsxFactory,

@@ -52,2 +54,3 @@ jsxFragmentFactory,

emitDecoratorMetadata,
jsx,
jsxFactory,

@@ -54,0 +57,0 @@ jsxFragmentFactory,

Sorry, the diff of this file is not supported yet

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