@originjs/openharmony-webpack-plugin

0.7.0 • Public • Published

openharmony-webpack-plugin

OpenHarmony Polyfill in Webpack.

Install

npm install @originjs/openharmony-webpack-plugin

at {YOUR_SDK_PATH}\Sdk\ets\3.0.0.0\build-tools\ets-loader

Usage

Add the following to your webpack.config.js: (at {YOUR_SDK_PATH}\Sdk\ets\3.0.0.0\build-tools\ets-loader)

const OpenHarmonyPolyfillPlugin = require('@originjs/openharmony-webpack-plugin');

module.exports = {
	// Other rules...
	plugins: [
		new OpenHarmonyPolyfillPlugin()
	]
}

API

Aliases

Globals

  • Buffer
  • process
  • crypto
  • fetch
  • XMLHttpRequest
  • TextDecoder
  • TextEncoder
  • URL
  • URLSearchParams

Modules

  • assert
  • buffer
  • crypto
  • domain
  • events
  • http
  • https
  • os
  • path
  • process
  • querystring
  • stream
  • url
  • util
  • fs

FAQ

TS2304: Cannot find name 'xx'

If you use these global API directly in ets, it may appear an TS2304 error. eg.

 ETS:ERROR File: examples\sdk7-demo\entry\src\main\ets\default\pages\textutil.ets:14:29
 TS2304: Cannot find name 'TextDecoder'.
 
 ETS:ERROR File: examples\sdk7-demo\entry\src\main\ets\default\pages\textutil.ets:31:29
 TS2304: Cannot find name 'TextEncoder'.
 
 ETS:ERROR File: examples\sdk7-demo\entry\src\main\ets\default\pages\textutil.ets:45:25
 TS2304: Cannot find name 'URL'.

Solutions: Add import statements:

import { TextDecoder } from 'openharmony-polyfill';
import { TextEncoder } from 'openharmony-polyfill';
import { URL } from 'openharmony-polyfill';

Readme

Keywords

none

Package Sidebar

Install

npm i @originjs/openharmony-webpack-plugin

Weekly Downloads

0

Version

0.7.0

License

MulanPSL-2.0

Unpacked Size

16.7 kB

Total Files

4

Last publish

Collaborators

  • flyfishzy
  • alan_scut
  • yuangongji
  • peteralfredlee
  • jiawulin