0.1.0 • Published 8 months ago

@lynx-js/web-platform-rsbuild-plugin v0.1.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
8 months ago

@lynx-js/web-platform-rsbuild-plugin

Lynx3 Web Platform rsbuild plugin

Usage

import { pluginWebPlatform } from '@lynx-js/web-platform-rsbuild-plugin';
import { defineConfig } from '@rsbuild/core';

export default defineConfig({
  plugins: [pluginWebPlatform({
    // replace with your actual native-modules file path
    nativeModulesPath: path.resolve(__dirname, './index.native-modules.ts'),
  })],
});

Options

{
  /**
   * Whether to polyfill the packages about Lynx Web Platform.
   *
   * If it is true, @lynx-js will be compiled and polyfills will be added.
   *
   * @default true
   */
  polyfill?: boolean;
  /**
   * The absolute path of the native-modules file.
   *
   * If you use it, you don't need to pass nativeModulesMap in the lynx-view tag, otherwise it will cause duplicate packaging.
   *
   * When enabled, nativeModules will be packaged directly into the worker chunk instead of being transferred through Blob.
   */
  nativeModulesPath?: string;
}

nativeModulesPath

native-modules.ts example:

// index.native-modules.ts
export default {
  CustomModule: function(NativeModules, NativeModulesCall) {
    return {
      async getColor(data, callback) {
        const color = await NativeModulesCall('getColor', data);
        callback(color);
      },
    };
  },
};
0.1.0

8 months ago