laravel-mix-swc
    TypeScript icon, indicating that this package has built-in type declarations

    0.3.0 • Public • Published

    Laravel Mix SWC

    Integrate SWC JavaScript compiler with Laravel Mix.

    We know how far Rust can be in terms of performance, this projects brings all its power for JavaScript compiling (doing all the job that Babel does but much faster!).

    Check its benchmarks here for more reference.

    Getting started

    Installing this in your Laravel project is very simple, run this command:

    yarn add -D laravel-mix-swc
    # or
    npm i --dev laravel-mix-swc

    And in your webpack.mix.js file in the root of your project add the following:

    // At the very top of your file:
    require("laravel-mix-swc");
    
    // And replace mix.ts(), mix.js() or mix.babel() with .swc():
    mix.swc("resources/js/app.js", "public/js")

    Configuration

    To configure SWC you can send options as third parameter:

    mix.swc("resources/js/app.js", "public/js", {
        jsc: {
            parser: {
                syntax: "ecmascript",
                jsx: false,
            }
        }
    })

    For more info check the official documentation of swc here.

    Config tips

    Some "presets" or lets call them like that, remember this is the default config: https://github.com/open-southeners/laravel-mix-swc/blob/e45a3f1b92a1130a1acda2de7801f1348df547b7/plugin.js#L6

    TypeScript with JavaScript

    {
        "test": ".*.ts$",
        "jsc": {
          "parser": {
            "syntax": "typescript"
          }
        }
    }

    JSX support

    {
        "jsc": {
          "parser": {
            "jsx": true
          }
        }
    }

    Vue support

    Very important that you've the decorators enabled, this also supports TypeScript but you can modify that.

    {
        "test": ".*.ts$",
        "jsc": {
            "parser": {
                "syntax": "typescript",
                "jsx": false,
                "decorators": true,
                "dynamicImport": true,
                "exportDefaultFrom": true
            }
        }
    }

    License

    This package is open-sourced software licensed under the MIT license.

    Keywords

    none

    Install

    npm i laravel-mix-swc

    DownloadsWeekly Downloads

    36

    Version

    0.3.0

    License

    MIT

    Unpacked Size

    8.77 kB

    Total Files

    9

    Last publish

    Collaborators

    • d8vjork