![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
vite-plugin-swc-transform
Advanced tools
Transform your TypeScript / JavaScript source files with SWC within your Vite build process.
Read the blog post relating the story which led to the creation of this plugin: TypeScript Legacy Experimental Decorators with Type Metadata in 2023.
npm i --save-dev vite-plugin-swc-transform
Note: This package is ESM-only.
import { defineConfig } from "vite";
import swc from "vite-plugin-swc-transform";
export default defineConfig({
plugins: [swc()],
});
The plugin will default to the following options:
{
include: /\.tsx?$/,
exclude: /node_modules/,
swcOptions: {
{
swcrc: false,
configFile: false,
inputSourceMap: false,
sourceMaps: true
}
},
suppressLegacyDecoratorNoExplicitUDFCFWarning: false
}
Example use case: build a package leveraging Nest style dependency injection with Reflect.metadata.
import { defineConfig } from "vite";
import swc from "vite-plugin-swc-transform";
export default defineConfig({
plugins: [
swc({
swcOptions: {
jsc: {
target: "es2022",
transform: {
legacyDecorator: true,
decoratorMetadata: true,
useDefineForClassFields: false,
},
// externalHelpers: true,
},
},
}),
],
});
Notes:
"compilerOptions.experimentalDecorators": true
& "compilerOptions.emitDecoratorMetadata": true
in your tsconfig.json
.swcOptions.jsc.externalHelpers: true
is recommended when transforming TypeScript Legacy / Experimental Decorators with Metadata to avoid helpers duplication & limit bundle size impact.
@swc/helpers
dependency is then necessary.The above (without external helpers) will yield the following SWC transform options:
{
swcrc: false,
configFile: false,
inputSourceMap: false,
sourceMaps: true,
jsc: {
target: 'es2022',
transform: {
legacyDecorator: true,
decoratorMetadata: true,
useDefineForClassFields: false
},
keepClassNames: true,
parser: {
decorators: true,
decoratorsBeforeExport: true,
syntax: 'typescript'
}
}
}
tsconfig.json
configuration.swcOptions
SWC configuration object.[vite-plugin-swc-transform] SWC option 'jsc.transform.legacyDecorator' enabled without an explicit 'jsc.transform.useDefineForClassFields' value.
To remove this warning, either:
- unset or disable SWC option 'jsc.transform.legacyDecorator' if not needed
- set an explicit value for SWC option 'jsc.transform.useDefineForClassFields: boolean'
- pass vite-plugin-swc-transform option 'suppressLegacyDecoratorNoExplicitUDFCFWarning: true'
Please open an issue if you think this is incorrect or should be improved.
FAQs
Vite plugin for transforming source files with SWC.
The npm package vite-plugin-swc-transform receives a total of 0 weekly downloads. As such, vite-plugin-swc-transform popularity was classified as not popular.
We found that vite-plugin-swc-transform demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.