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.3.0 to 0.4.0

4

dist/index.d.ts
import { Plugin } from 'rollup';
import { FilterPattern } from '@rollup/pluginutils';
import { Config, JsMinifyOptions } from '@swc/core';
import { Options, JsMinifyOptions } from '@swc/core';

@@ -13,3 +13,3 @@ declare type PluginOptions = {

tsconfig?: string | false;
} & Pick<Config, Exclude<keyof Config, 'filename' & 'include' & 'exclude'>>;
} & Pick<Options, Exclude<keyof Options, 'filename' & 'include' & 'exclude'>>;
declare function swc(options?: PluginOptions): Plugin;

@@ -16,0 +16,0 @@ declare function minify(options?: JsMinifyOptions): Plugin;

@@ -53,9 +53,10 @@ 'use strict';

const INCLUDE_REGEXP = /\.m?[jt]sx?$/;
const INCLUDE_REGEXP = /\.[mc]?[jt]sx?$/;
const EXCLUDE_REGEXP = /node_modules/;
const ACCEPTED_EXTENSIONS = [
'.ts',
'.tsx',
'.mjs',
'.js',
'.tsx',
'.cjs',
'.jsx'

@@ -69,4 +70,5 @@ ];

const resolveFile = async (resolved, index = false)=>{
const fileWithoutExt = path.join(path.dirname(resolved), path.basename(resolved, path.extname(resolved)));
for (const ext of ACCEPTED_EXTENSIONS){
const file = index ? path.join(resolved, `index${ext}`) : `${resolved}${ext}`;
const file = index ? path.join(resolved, `index${ext}`) : `${fileWithoutExt}${ext}`;
// We only check one file at a time, and we can return early

@@ -109,2 +111,3 @@ // eslint-disable-next-line no-await-in-loop

const swcOptionsFromTsConfig = {
filename: id,
jsc: {

@@ -111,0 +114,0 @@ externalHelpers: tsconfigOptions.importHelpers,

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

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -1,2 +0,1 @@

<div align="center">

@@ -11,11 +10,11 @@ <img src="https://pic.skk.moe/file/sukkaw/gh/rollup-plugin-swc.png" width="550px">

| | [sukkaw/rollup-plugin-swc](https://github.com/SukkaW/rollup-plugin-swc) | [mentaljam/rollup-plugin-swc](https://github.com/mentaljam/rollup-plugin-swc) | [nicholasxjy/rollup-plugin-swc2](https://github.com/nicholasxjy/rollup-plugin-swc2)
| --- | --- | --- | --- |
| `minify` your bundle in one pass[^1] | Yes | No | No |
| Standalone `swcMinify` plugin | Yes | No | No |
| Config Intellisense[^2] | Yes | No | No |
| Reads your `tsconfig.json` and `jsconfig.json` | Yes[^3] | No | No |
| ESM export | Full | Partial[^4] | No |
| TypeScrit declarations | Yes | Yes | Yes |
| Has testing | Yes | No | No |
| | [sukkaw/rollup-plugin-swc](https://github.com/SukkaW/rollup-plugin-swc) | [mentaljam/rollup-plugin-swc](https://github.com/mentaljam/rollup-plugin-swc) | [nicholasxjy/rollup-plugin-swc2](https://github.com/nicholasxjy/rollup-plugin-swc2) |
| ---------------------------------------------- | ----------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| `minify` your bundle in one pass[^1] | Yes | No | No |
| Standalone `swcMinify` plugin | Yes | No | No |
| Config Intellisense[^2] | Yes | No | No |
| Reads your `tsconfig.json` and `jsconfig.json` | Yes[^3] | No | No |
| ESM export | Full | Partial[^4] | No |
| TypeScrit declarations | Yes | Yes | Yes |
| Has testing | Yes | No | No |

@@ -46,3 +45,3 @@ [^1]: If minify is called in Rollup's `transform` phase, every individual module processed will result in a minify call. However, if minify is called in Rollup's `renderChunk` phase, the minify will only be called once in one whole pass before Rollup generates bundle, results in a faster build.

output: {},
plugin: [
plugins: [
swc({

@@ -69,3 +68,3 @@ // All options are optional

output: {},
plugin: [
plugins: [
swc(defineRollupSwcOption({

@@ -78,3 +77,3 @@ // ... There goes the plugin's configuration

// or
/** @type {imoprt('rollup-plugin-swc3').PluginOptions} */
/** @type {import('rollup-plugin-swc3').PluginOptions} */
const swcPluginConfig = {}

@@ -97,7 +96,9 @@ ```

export default {
plugins: [minify({
// swc's minify option here
// mangle: {}
// compress: {}
})],
plugins: [
minify({
// swc's minify option here
// mangle: {}
// compress: {}
}),
],
}

@@ -112,7 +113,11 @@ ```

export default {
plugins: [minify(defineRollupSwcMinifyOption({
// swc's minify option here
// mangle: {}
// compress: {}
}))],
plugins: [
minify(
defineRollupSwcMinifyOption({
// swc's minify option here
// mangle: {}
// compress: {}
})
),
],
}

@@ -152,8 +157,10 @@

output: {},
plugin: [
plugins: [
vueJsx(),
swc(defineRollupSwcOption({
jsc: {
react: {
pragma: 'vueJsxCompat'
transform: {
react: {
pragma: 'vueJsxCompat'
}
}

@@ -173,7 +180,8 @@ }

output: {},
plugin: [
plugins: [
vueJsx(),
swc(defineRollupSwcOption({
jsc: {
react: {
transform:{
react: {
pragma: 'h',

@@ -184,2 +192,3 @@ pragmaFrag: 'Fragment'

// runtime: 'automatic'
}
}

@@ -192,3 +201,3 @@ }

----
---

@@ -195,0 +204,0 @@ **rollup-plugin-swc** © [Sukka](https://github.com/SukkaW), Released under the [MIT](./LICENSE) License.<br>

import type { Plugin } from 'rollup';
import fs from 'fs';
import { extname, resolve, dirname, join } from 'path';
import { extname, resolve, dirname, join, basename } from 'path';
import { createFilter, FilterPattern } from '@rollup/pluginutils';
import { Config as SwcConfig, JscTarget, transform as swcTransform, minify as swcMinify, JsMinifyOptions } from '@swc/core';
import { Options as SwcOptions, JscTarget, transform as swcTransform, minify as swcMinify, JsMinifyOptions } from '@swc/core';
import deepmerge from 'deepmerge';

@@ -19,8 +19,8 @@

tsconfig?: string | false
} & Pick<SwcConfig, Exclude<keyof SwcConfig, 'filename' & 'include' & 'exclude'>>;
} & Pick<SwcOptions, Exclude<keyof SwcOptions, 'filename' & 'include' & 'exclude'>>;
const INCLUDE_REGEXP = /\.m?[jt]sx?$/;
const INCLUDE_REGEXP = /\.[mc]?[jt]sx?$/;
const EXCLUDE_REGEXP = /node_modules/;
const ACCEPTED_EXTENSIONS = ['.ts', '.mjs', '.js', '.tsx', '.jsx'];
const ACCEPTED_EXTENSIONS = ['.ts', '.tsx', '.mjs', '.js', '.cjs', '.jsx'];

@@ -34,4 +34,6 @@ const fileExists = (path: string) => {

const resolveFile = async (resolved: string, index = false) => {
const fileWithoutExt = join(dirname(resolved), basename(resolved, extname(resolved)))
for (const ext of ACCEPTED_EXTENSIONS) {
const file = index ? join(resolved, `index${ext}`) : `${resolved}${ext}`;
const file = index ? join(resolved, `index${ext}`) : `${fileWithoutExt}${ext}`;
// We only check one file at a time, and we can return early

@@ -92,3 +94,4 @@ // eslint-disable-next-line no-await-in-loop

const swcOptionsFromTsConfig: SwcConfig = {
const swcOptionsFromTsConfig: SwcOptions = {
filename: id,
jsc: {

@@ -115,3 +118,3 @@ externalHelpers: tsconfigOptions.importHelpers,

const swcOption = deepmerge.all<SwcConfig>([
const swcOption = deepmerge.all<SwcOptions>([
swcOptionsFromTsConfig,

@@ -118,0 +121,0 @@ options,

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