0.6.1 • Published 9 months ago

@shopify/async-swc-plugin v0.6.1

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

shopify_async_swc_plugin

Plugin for @shopify/async.

This plugin will look for any functions imported from the specified packages. It will then iterate over each reference to that function and, if the reference is a call expression where the first argument is an object, and that object has a load function, will mark it for processing. The adjustment is simple: it simply adds an id method that returns a Webpack-specific identifier based on the first dynamic import in the load method, allowing the function to use this identifier to mark the module as used.

import { createAsyncComponent } from "my-package";

createAsyncComponent({
  load: () => import("../SomeComponent"),
});

// Becomes:

createAsyncComponent({
  load: () => import("../SomeComponent"),
  id: () => require.resolveWeak("../SomeComponent"),
});

Usage

To load plugins, you may use swcrc's jsc.experimental configs:

{
  jsc: {
    ...
   experimental: {
     ...
     cache_root: String // optional, specify where swc will create wasm bytecode cache
    // list of plugins. If `pluginname` is resolvable to npm package, it'll try to load from installed npm packages.
    // or it can be an absolute path to the .wasm binary
     plugins: [ ['@shopify/async-swc-plugin'] ]
   }
}
0.6.1

9 months ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.1

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago