@oveo/optimizer 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +1 -88
  2. package/index.d.ts +18 -4
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -1,88 +1 @@
1
- # `@napi-rs/package-template`
2
-
3
- ![https://github.com/napi-rs/package-template/actions](https://github.com/napi-rs/package-template/workflows/CI/badge.svg)
4
-
5
- > Template project for writing node packages with napi-rs.
6
-
7
- # Usage
8
-
9
- 1. Click **Use this template**.
10
- 2. **Clone** your project.
11
- 3. Run `yarn install` to install dependencies.
12
- 4. Run `npx napi rename -n [name]` command under the project folder to rename your package.
13
-
14
- ## Install this test package
15
-
16
- ```
17
- yarn add @napi-rs/package-template
18
- ```
19
-
20
- ## Support matrix
21
-
22
-
23
- ## Ability
24
-
25
- ### Build
26
-
27
- After `yarn build/npm run build` command, you can see `package-template.[darwin|win32|linux].node` file in project root. This is the native addon built from [lib.rs](./src/lib.rs).
28
-
29
- ### Test
30
-
31
- With [ava](https://github.com/avajs/ava), run `yarn test/npm run test` to testing native addon. You can also switch to another testing framework if you want.
32
-
33
- ### CI
34
-
35
- With GitHub Actions, each commit and pull request will be built and tested automatically in [`node@14`, `node@16`, `@node18`] x [`macOS`, `Linux`, `Windows`] matrix. You will never be afraid of the native addon broken in these platforms.
36
-
37
- ### Release
38
-
39
- Release native package is very difficult in old days. Native packages may ask developers who use it to install `build toolchain` like `gcc/llvm`, `node-gyp` or something more.
40
-
41
- With `GitHub actions`, we can easily prebuild a `binary` for major platforms. And with `N-API`, we should never be afraid of **ABI Compatible**.
42
-
43
- The other problem is how to deliver prebuild `binary` to users. Downloading it in `postinstall` script is a common way that most packages do it right now. The problem with this solution is it introduced many other packages to download binary that has not been used by `runtime codes`. The other problem is some users may not easily download the binary from `GitHub/CDN` if they are behind a private network (But in most cases, they have a private NPM mirror).
44
-
45
- In this package, we choose a better way to solve this problem. We release different `npm packages` for different platforms. And add it to `optionalDependencies` before releasing the `Major` package to npm.
46
-
47
- `NPM` will choose which native package should download from `registry` automatically. You can see [npm](./npm) dir for details. And you can also run `yarn add @napi-rs/package-template` to see how it works.
48
-
49
- ## Develop requirements
50
-
51
- - Install the latest `Rust`
52
- - Install `Node.js@10+` which fully supported `Node-API`
53
- - Install `yarn@1.x`
54
-
55
- ## Test in local
56
-
57
- - yarn
58
- - yarn build
59
- - yarn test
60
-
61
- And you will see:
62
-
63
- ```bash
64
- $ ava --verbose
65
-
66
- ✔ sync function from native code
67
- ✔ sleep function from native code (201ms)
68
-
69
-
70
- 2 tests passed
71
- ✨ Done in 1.12s.
72
- ```
73
-
74
- ## Release package
75
-
76
- Ensure you have set your **NPM_TOKEN** in the `GitHub` project setting.
77
-
78
- In `Settings -> Secrets`, add **NPM_TOKEN** into it.
79
-
80
- When you want to release the package:
81
-
82
- ```
83
- npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease [--preid=<prerelease-id>] | from-git]
84
-
85
- git push
86
- ```
87
-
88
- GitHub actions will do the rest job for you.
1
+ NAPI bindings for the [oveo](https://github.com/localvoid/oveo) javascript optimizer.
package/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export declare class Optimizer {
4
4
  constructor(options?: OptimizerOptions | undefined | null)
5
5
  importExterns(data: Uint8Array): void
6
6
  importPropertyMap(data: Uint8Array): void
7
+ exportPropertyMap(): Uint8Array
7
8
  optimizeModule(sourceText: string): Promise<OptimizerOutput>
8
9
  optimizeChunk(sourceText: string): Promise<OptimizerOutput>
9
10
  }
@@ -13,11 +14,24 @@ export declare class OptimizerOutput {
13
14
  map: string
14
15
  }
15
16
 
17
+ export interface ExternsOptions {
18
+ inlineConstValues?: boolean
19
+ }
20
+
21
+ export interface GlobalsOptions {
22
+ include?: Array<string>
23
+ hoist?: boolean
24
+ singletons?: boolean
25
+ }
26
+
16
27
  export interface OptimizerOptions {
17
28
  hoist?: boolean
18
29
  dedupe?: boolean
19
- hoistGlobals?: boolean
20
- inlineExternValues?: boolean
21
- singletons?: boolean
22
- renameProperties?: boolean
30
+ globals?: GlobalsOptions
31
+ externs?: ExternsOptions
32
+ renameProperties?: RenamePropertiesOptions
33
+ }
34
+
35
+ export interface RenamePropertiesOptions {
36
+ pattern?: string
23
37
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oveo/optimizer",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {