void 0.10.5 → 0.10.7
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.
- package/dist/agents-Bmr5tFFb.mjs +1454 -0
- package/dist/{auth-cmd-UoCwfDQv.mjs → auth-cmd-DlgNwByu.mjs} +10 -10
- package/dist/{better-auth-shared-D0Mbmx5V.mjs → better-auth-shared-BQooDxbw.mjs} +1 -1
- package/dist/{better-auth-shared-jkksALri.d.mts → better-auth-shared-BvnM9px6.d.mts} +2 -2
- package/dist/{build-cmd-CVyuBHjP.mjs → build-cmd-Br8qL0rA.mjs} +15 -17
- package/dist/{cache-ACORQCIq.mjs → cache-wH-mP8UE.mjs} +10 -12
- package/dist/{cancel-deploy-Gi8zmoZC.mjs → cancel-deploy-BEBOEgtu.mjs} +16 -18
- package/dist/cli/cli.mjs +47 -49
- package/dist/{client-BlbnA92X.mjs → client-Cj96iiBH.mjs} +74 -8
- package/dist/{config-8dLIngKW.mjs → config-1twldYCW.mjs} +10 -10
- package/dist/{config-CbJS4Krx.mjs → config-BdUctCZD.mjs} +4 -4
- package/dist/{create-project-LjvkYziS.mjs → create-project-DD9n8Ho-.mjs} +28 -23
- package/dist/{db-C00yjN01.mjs → db-DjKE2-A-.mjs} +147 -149
- package/dist/{delete-CplfvTgU.mjs → delete-D2kr3Kmk.mjs} +13 -15
- package/dist/{deploy-CISNL5uK.mjs → deploy-C4PbkFyE.mjs} +97 -100
- package/dist/{discover-ZWuBvt22.mjs → discover-BuVVSAum.mjs} +3 -3
- package/dist/{dist-5cGIJHQQ.mjs → dist-BuiRJkTd.mjs} +59 -27
- package/dist/{domain-B4HpcgNG.mjs → domain-_luIsM_B.mjs} +14 -16
- package/dist/{env-DNMJpeVF.mjs → env-CO5XAS9t.mjs} +23 -25
- package/dist/{env-helpers-B_ks681T.d.mts → env-helpers-z4stu8uc.d.mts} +1 -1
- package/dist/{env-types-BS8cZead.mjs → env-types-D51bnR-c.mjs} +3 -3
- package/dist/{env-validation-BxbtBbjh.mjs → env-validation-CeC2FL66.mjs} +4 -4
- package/dist/{fetch-error-C6qffTl2.mjs → fetch-error-Dj3crt0e.mjs} +3 -3
- package/dist/{gen-C0pV2gRQ.mjs → gen-Cf79J4aw.mjs} +42 -44
- package/dist/{github-cmd-CwtLD1yI.mjs → github-cmd-DnqxyOsb.mjs} +88 -90
- package/dist/{handler-B7rCOy21.d.mts → handler-imD0UVDT.d.mts} +4 -5
- package/dist/{headers-BNWymgnH.mjs → headers-BwvFGhkx.mjs} +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +102 -83
- package/dist/{init-D58GxCtt.mjs → init-KirOzVDs.mjs} +132 -134
- package/dist/link-CUmiosyb.mjs +45 -0
- package/dist/{list-CbNNjXTm.mjs → list-3GEw7b6m.mjs} +10 -12
- package/dist/{login-CvxxF_9z.mjs → login-DJReaT_Q.mjs} +14 -15
- package/dist/{logs-BDZ9AuhM.mjs → logs-D-rQ56Lq.mjs} +9 -11
- package/dist/{magic-string.es-C1Fb0uxq.mjs → magic-string.es-ZQjdJFFn.mjs} +3 -3
- package/dist/{mcp-C8BjRt_z.mjs → mcp-D7yc0dXY.mjs} +2 -3
- package/dist/{node-B07cZs0d.mjs → node-yFFk626c.mjs} +6 -6
- package/dist/{package-json-Bg_GJdJB.mjs → package-json-B0NuUWGd.mjs} +1 -1
- package/dist/pages/client.d.mts +1 -1
- package/dist/pages/client.mjs +2 -1
- package/dist/pages/head-client.d.mts +1 -1
- package/dist/pages/head.d.mts +1 -1
- package/dist/pages/index.d.mts +2 -2
- package/dist/pages/index.mjs +5 -5
- package/dist/pages/islands-plugin.d.mts +1 -1
- package/dist/pages/islands-plugin.mjs +3 -3
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +5 -2
- package/dist/{plugin-inference-D04iL1mW.mjs → plugin-inference-CJxi_fWI.mjs} +3 -3
- package/dist/{prepare-DUo9q8cM.mjs → prepare-C_cVurhP.mjs} +15 -18
- package/dist/{preset-D0My64KQ.mjs → preset-CVvwCeIy.mjs} +4 -4
- package/dist/{project-cmd-Dd1gNRdd.mjs → project-cmd-DnU7u9QF.mjs} +13 -14
- package/dist/{project-paths-CCMrHYQm.mjs → project-paths-tpdR1mJR.mjs} +2 -2
- package/dist/{project-tsconfig-DMBV55K2.mjs → project-tsconfig-D9uSVVpA.mjs} +2 -2
- package/dist/{protocol-6UZCowS1.d.mts → protocol-6hTJ04T1.d.mts} +3 -3
- package/dist/{resolve-project-D4O1_fZz.mjs → resolve-project-D2HI3TrG.mjs} +2 -2
- package/dist/{rollback-DzmCCrFg.mjs → rollback-Yh7bCKob.mjs} +21 -23
- package/dist/{route-types-BpSJEW20.mjs → route-types-CfKfhbIg.mjs} +234 -3
- package/dist/{runner-BQyKUqAL.mjs → runner-h272wcPj.mjs} +4 -5
- package/dist/{runner-pg-EuhrFW3D.mjs → runner-pg-waxJOnBb.mjs} +1 -1
- package/dist/runtime/ai.mjs +2 -2
- package/dist/runtime/auth.d.mts +1 -1
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth-pg.mjs +3 -3
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/better-auth.mjs +2 -2
- package/dist/runtime/client-react.d.mts +2 -2
- package/dist/runtime/client-react.mjs +1 -1
- package/dist/runtime/client-solid.d.mts +2 -2
- package/dist/runtime/client-solid.mjs +1 -1
- package/dist/runtime/client-svelte.d.mts +2 -2
- package/dist/runtime/client-svelte.mjs +1 -1
- package/dist/runtime/client-vue.d.mts +2 -2
- package/dist/runtime/client-vue.mjs +1 -1
- package/dist/runtime/client.d.mts +2 -2
- package/dist/runtime/client.mjs +1 -1
- package/dist/runtime/db-pg.d.mts +1 -1
- package/dist/runtime/env-helpers.d.mts +1 -1
- package/dist/runtime/env-public-client.d.mts +1 -1
- package/dist/runtime/env-public-client.mjs +2 -0
- package/dist/runtime/env-public.d.mts +3 -4
- package/dist/runtime/env-public.mjs +3 -1
- package/dist/runtime/env.mjs +1 -1
- package/dist/runtime/fetch-stream.d.mts +1 -1
- package/dist/runtime/fetch-stream.mjs +1 -1
- package/dist/runtime/fetch.d.mts +1 -1
- package/dist/runtime/fetch.mjs +1 -1
- package/dist/runtime/handler.d.mts +2 -2
- package/dist/runtime/handler.mjs +1 -1
- package/dist/runtime/isr.mjs +1 -1
- package/dist/runtime/live-server.mjs +2 -0
- package/dist/runtime/live.d.mts +2 -2
- package/dist/runtime/live.mjs +3 -1
- package/dist/runtime/migration-handler-pg.mjs +1 -1
- package/dist/runtime/migration-handler.mjs +1 -1
- package/dist/runtime/remote/index.mjs +11 -1
- package/dist/runtime/sandbox.d.mts +1 -4
- package/dist/runtime/sandbox.mjs +1 -1
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/ws-server.d.mts +2 -2
- package/dist/runtime/ws-server.mjs +2 -0
- package/dist/runtime/ws.d.mts +3 -3
- package/dist/runtime/ws.mjs +2 -0
- package/dist/{scan-VCAM1oh3.mjs → scan-Dp_Gyzs3.mjs} +3 -3
- package/dist/{scan---8wfN58.mjs → scan-i7Yz54fv.mjs} +26 -8
- package/dist/{secret-CMLYWkE-.mjs → secret-u7FRvg8d.mjs} +22 -24
- package/dist/{skills-Dl3u05da.mjs → skills-DsdNDtX3.mjs} +6 -7
- package/dist/{subcommand-prompt-B8ng0FTS.mjs → subcommand-prompt-DtES-oP6.mjs} +34 -35
- package/dist/sveltekit.mjs +1 -1
- package/dist/validate-DT7nFMlf.mjs +504 -0
- package/dist/{yarn-pnp-WLW2IHUY.mjs → yarn-pnp-CW8LB6g_.mjs} +1 -1
- package/package.json +19 -19
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/CHANGELOG.md +94 -0
- package/skills/void/docs/node_modules/void/node_modules/@clack/prompts/README.md +32 -11
- package/skills/void/docs/node_modules/void/node_modules/@cloudflare/sandbox/README.md +45 -0
- package/skills/void/docs/node_modules/void/node_modules/@electric-sql/pglite/README.md +5 -5
- package/skills/void/docs/node_modules/void/node_modules/@types/node/README.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/@types/node/README.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/markdown-exit/README.md +4 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/tinyglobby/README.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/AGENTS.md +1 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/README.md +18 -6
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/build.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/check.md +35 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/create.md +70 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/fmt.md +3 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/index.md +11 -7
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/lint.md +3 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/pack.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/run.md +141 -26
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/staged.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/config/test.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/automatic-data-tracking.md +145 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/cache.md +16 -28
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/check.md +16 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/ci.md +15 -17
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/commit-hooks.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/create.md +255 -2
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/docker.md +175 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/env.md +70 -5
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/github-actions-cache.md +165 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/ide-integration.md +2 -2
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/index.md +9 -3
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/install.md +63 -11
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/migrate-rules.md +347 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/migrate.md +27 -3
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/monorepo.md +176 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/pack.md +8 -0
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/run.md +36 -4
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/troubleshooting.md +11 -35
- package/skills/void/docs/node_modules/void/node_modules/@void/md/node_modules/vite-plus/docs/guide/upgrade.md +65 -13
- package/skills/void/docs/node_modules/void/node_modules/es-module-lexer/README.md +403 -390
- package/skills/void/docs/node_modules/void/node_modules/pg/README.md +2 -1
- package/skills/void/docs/node_modules/void/node_modules/tinyglobby/README.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/AGENTS.md +1 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/README.md +18 -6
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/build.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/check.md +35 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/create.md +70 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/fmt.md +3 -1
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/index.md +11 -7
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/lint.md +3 -1
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/pack.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/run.md +141 -26
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/staged.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/config/test.md +1 -1
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/automatic-data-tracking.md +145 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/cache.md +16 -28
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/check.md +16 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/ci.md +15 -17
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/commit-hooks.md +9 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/create.md +255 -2
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/docker.md +175 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/env.md +70 -5
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/github-actions-cache.md +165 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/ide-integration.md +2 -2
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/index.md +9 -3
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/install.md +63 -11
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/migrate-rules.md +347 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/migrate.md +27 -3
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/monorepo.md +176 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/pack.md +8 -0
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/run.md +36 -4
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/troubleshooting.md +11 -35
- package/skills/void/docs/node_modules/void/node_modules/vite-plus/docs/guide/upgrade.md +65 -13
- package/skills/void/docs/reference/cli.md +5 -1
- package/dist/agents-MhSzNMiC.mjs +0 -151
- package/dist/collect-9rO3JFNM.mjs +0 -55
- package/dist/config-hhMYPVRT.mjs +0 -21
- package/dist/dist-abzUneor.mjs +0 -1287
- package/dist/drizzle-DqstQTGq.mjs +0 -232
- package/dist/link-ZFmboqY3.mjs +0 -47
- package/dist/output-DeiS4oEX.mjs +0 -139
- package/dist/plan-aD3wRDqF.mjs +0 -271
- package/dist/project-CH9pdo16.mjs +0 -72
- package/dist/project-slug-rX3kTOfY.mjs +0 -10
- package/dist/validate-CNWm-PsL.mjs +0 -186
- /package/dist/{auth-migrations-BP-hMzYl.mjs → auth-migrations-BTZ-ATvQ.mjs} +0 -0
- /package/dist/{auth-Dz2CCn4T.d.mts → auth-qgMlYp7Z.d.mts} +0 -0
- /package/dist/{canonical-json-CEyQaVDa.mjs → canonical-json-DuDiiUsQ.mjs} +0 -0
- /package/dist/{cf-access-DKDsgwOU.mjs → cf-access-Bqw81xAf.mjs} +0 -0
- /package/dist/{defer-C-bdSM_b.mjs → defer-YsYDUoii.mjs} +0 -0
- /package/dist/{dotenv-lS94ymhM.mjs → dotenv-D_UbC_vc.mjs} +0 -0
- /package/dist/{env-raw-Dtj1UAoK.mjs → env-raw-CoS20LHP.mjs} +0 -0
- /package/dist/{fetch-error-B6RaJ-eZ.d.mts → fetch-error-Sp1R4mZv.d.mts} +0 -0
- /package/dist/{git-metadata-Ce0AtSZL.mjs → git-metadata-CBKaL0v5.mjs} +0 -0
- /package/dist/{head-eOUCWUNy.d.mts → head-nmvOgFjd.d.mts} +0 -0
- /package/dist/{log-BdD_Fpms.mjs → log-ChfPKsVd.mjs} +0 -0
- /package/dist/{pathe.M-eThtNZ-BrPhGF_K.mjs → pathe.M-eThtNZ-CQzLbt4c.mjs} +0 -0
- /package/dist/{pg-CempqvEJ.mjs → pg-J2HbZIkX.mjs} +0 -0
- /package/dist/{providers-BJIoduK9.d.mts → providers-BNKRacMr.d.mts} +0 -0
- /package/dist/{providers-BwPbdHdi.mjs → providers-CJlNS3kT.mjs} +0 -0
- /package/dist/{proxy-M3pxItg2.mjs → proxy-D-3_D-Gl.mjs} +0 -0
- /package/dist/{chunk-DJd-R1mw.mjs → rolldown-runtime-DJK8HYOj.mjs} +0 -0
- /package/dist/{standard-schema-Cy0lfeWv.d.mts → standard-schema-DJ0HW7QP.d.mts} +0 -0
- /package/dist/{types-BodZGegX.d.mts → types-lLjNE9Qp.d.mts} +0 -0
|
@@ -1,390 +1,403 @@
|
|
|
1
|
-
# ES Module Lexer
|
|
2
|
-
|
|
3
|
-
[![Build Status][actions-image]][actions-url]
|
|
4
|
-
|
|
5
|
-
A JS module syntax lexer used in [es-module-shims](https://github.com/guybedford/es-module-shims).
|
|
6
|
-
|
|
7
|
-
Outputs the list of exports and locations of import specifiers, including dynamic import and import meta handling.
|
|
8
|
-
|
|
9
|
-
Supports new syntax features including import attributes and source phase imports.
|
|
10
|
-
|
|
11
|
-
A very small single JS file (
|
|
12
|
-
|
|
13
|
-
For an example of the performance, Angular 1 (720KiB) is fully parsed in 5ms, in comparison to the fastest JS parser, Acorn which takes over 100ms.
|
|
14
|
-
|
|
15
|
-
_Comprehensively handles the JS language grammar while remaining small and fast. - ~10ms per MB of JS cold and ~5ms per MB of JS warm, [see benchmarks](#benchmarks) for more info._
|
|
16
|
-
|
|
17
|
-
> [Built with](https://github.com/guybedford/es-module-lexer/blob/main/chompfile.toml) [Chomp](https://chompbuild.com/)
|
|
18
|
-
|
|
19
|
-
### Usage
|
|
20
|
-
|
|
21
|
-
```
|
|
22
|
-
npm install es-module-lexer
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
See [src/lexer.ts](src/lexer.ts) for the type definitions.
|
|
26
|
-
|
|
27
|
-
For use in CommonJS:
|
|
28
|
-
|
|
29
|
-
```js
|
|
30
|
-
const { init, parse } = require('es-module-lexer');
|
|
31
|
-
|
|
32
|
-
(async () => {
|
|
33
|
-
// either await init, or call parse asynchronously
|
|
34
|
-
// this is necessary for the Web Assembly boot
|
|
35
|
-
await init;
|
|
36
|
-
|
|
37
|
-
const source = 'export var p = 5';
|
|
38
|
-
const [imports, exports] = parse(source);
|
|
39
|
-
|
|
40
|
-
// Returns "p"
|
|
41
|
-
source.slice(exports[0].s, exports[0].e);
|
|
42
|
-
// Returns "p"
|
|
43
|
-
source.slice(exports[0].ls, exports[0].le);
|
|
44
|
-
})();
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
An ES module version is also available:
|
|
48
|
-
|
|
49
|
-
```js
|
|
50
|
-
import { init, parse } from 'es-module-lexer';
|
|
51
|
-
|
|
52
|
-
(async () => {
|
|
53
|
-
await init;
|
|
54
|
-
|
|
55
|
-
const source = `
|
|
56
|
-
import { name } from 'mod\\u1011';
|
|
57
|
-
import json from './json.json' with { type: 'json' }
|
|
58
|
-
export var p = 5;
|
|
59
|
-
export function q () {
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
export { x as 'external name' } from 'external';
|
|
63
|
-
|
|
64
|
-
// Comments provided to demonstrate edge cases
|
|
65
|
-
import /*comment!*/ ( 'asdf', { with: { type: 'json' }});
|
|
66
|
-
import /*comment!*/.meta.asdf;
|
|
67
|
-
|
|
68
|
-
// Source phase imports:
|
|
69
|
-
import source mod from './mod.wasm';
|
|
70
|
-
import.source('./mod.wasm');
|
|
71
|
-
`;
|
|
72
|
-
|
|
73
|
-
const [imports, exports] = parse(source, 'optional-sourcename');
|
|
74
|
-
|
|
75
|
-
// Returns "modထ"
|
|
76
|
-
imports[0].n
|
|
77
|
-
// Returns "mod\u1011"
|
|
78
|
-
source.slice(imports[0].s, imports[0].e);
|
|
79
|
-
// "s" = start
|
|
80
|
-
// "e" = end
|
|
81
|
-
|
|
82
|
-
// Returns "import { name } from 'mod'"
|
|
83
|
-
source.slice(imports[0].ss, imports[0].se);
|
|
84
|
-
// "ss" = statement start
|
|
85
|
-
// "se" = statement end
|
|
86
|
-
|
|
87
|
-
// Returns "{ type: 'json' }"
|
|
88
|
-
source.slice(imports[1].a, imports[1].se);
|
|
89
|
-
// "a" = attribute start, -1 for no import attributes
|
|
90
|
-
|
|
91
|
-
// Parsed import attributes are available in `at`
|
|
92
|
-
// Returns [['type', 'json']]
|
|
93
|
-
imports[1].at;
|
|
94
|
-
// Returns 'json'
|
|
95
|
-
imports[1].at[0][1];
|
|
96
|
-
|
|
97
|
-
// Returns null (no attributes)
|
|
98
|
-
imports[0].at;
|
|
99
|
-
|
|
100
|
-
// Returns "external"
|
|
101
|
-
source.slice(imports[2].s, imports[2].e);
|
|
102
|
-
|
|
103
|
-
// Returns "p"
|
|
104
|
-
source.slice(exports[0].s, exports[0].e);
|
|
105
|
-
// Returns "p"
|
|
106
|
-
source.slice(exports[0].ls, exports[0].le);
|
|
107
|
-
// Returns "q"
|
|
108
|
-
source.slice(exports[1].s, exports[1].e);
|
|
109
|
-
// Returns "q"
|
|
110
|
-
source.slice(exports[1].ls, exports[1].le);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// Returns
|
|
114
|
-
exports[
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
//
|
|
119
|
-
|
|
120
|
-
// Returns
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
//
|
|
124
|
-
|
|
125
|
-
// Returns
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
// For
|
|
140
|
-
//
|
|
141
|
-
|
|
142
|
-
//
|
|
143
|
-
|
|
144
|
-
imports
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
//
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
//
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
import
|
|
203
|
-
import
|
|
204
|
-
`);
|
|
205
|
-
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
>
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
>
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
> 2ms
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
1
|
+
# ES Module Lexer
|
|
2
|
+
|
|
3
|
+
[![Build Status][actions-image]][actions-url]
|
|
4
|
+
|
|
5
|
+
A JS module syntax lexer used in [es-module-shims](https://github.com/guybedford/es-module-shims).
|
|
6
|
+
|
|
7
|
+
Outputs the list of exports and locations of import specifiers, including dynamic import and import meta handling.
|
|
8
|
+
|
|
9
|
+
Supports new syntax features including import attributes and source phase imports.
|
|
10
|
+
|
|
11
|
+
A very small single JS file (~7KiB gzipped) that includes inlined Web Assembly for very fast source analysis of ECMAScript module syntax only.
|
|
12
|
+
|
|
13
|
+
For an example of the performance, Angular 1 (720KiB) is fully parsed in 5ms, in comparison to the fastest JS parser, Acorn which takes over 100ms.
|
|
14
|
+
|
|
15
|
+
_Comprehensively handles the JS language grammar while remaining small and fast. - ~10ms per MB of JS cold and ~5ms per MB of JS warm, [see benchmarks](#benchmarks) for more info._
|
|
16
|
+
|
|
17
|
+
> [Built with](https://github.com/guybedford/es-module-lexer/blob/main/chompfile.toml) [Chomp](https://chompbuild.com/)
|
|
18
|
+
|
|
19
|
+
### Usage
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
npm install es-module-lexer
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
See [src/lexer.ts](src/lexer.ts) for the type definitions.
|
|
26
|
+
|
|
27
|
+
For use in CommonJS:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
const { init, parse } = require('es-module-lexer');
|
|
31
|
+
|
|
32
|
+
(async () => {
|
|
33
|
+
// either await init, or call parse asynchronously
|
|
34
|
+
// this is necessary for the Web Assembly boot
|
|
35
|
+
await init;
|
|
36
|
+
|
|
37
|
+
const source = 'export var p = 5';
|
|
38
|
+
const [imports, exports] = parse(source);
|
|
39
|
+
|
|
40
|
+
// Returns "p"
|
|
41
|
+
source.slice(exports[0].s, exports[0].e);
|
|
42
|
+
// Returns "p"
|
|
43
|
+
source.slice(exports[0].ls, exports[0].le);
|
|
44
|
+
})();
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
An ES module version is also available:
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import { init, parse } from 'es-module-lexer';
|
|
51
|
+
|
|
52
|
+
(async () => {
|
|
53
|
+
await init;
|
|
54
|
+
|
|
55
|
+
const source = `
|
|
56
|
+
import { name } from 'mod\\u1011';
|
|
57
|
+
import json from './json.json' with { type: 'json' }
|
|
58
|
+
export var p = 5;
|
|
59
|
+
export function q () {
|
|
60
|
+
|
|
61
|
+
};
|
|
62
|
+
export { x as 'external name' } from 'external';
|
|
63
|
+
|
|
64
|
+
// Comments provided to demonstrate edge cases
|
|
65
|
+
import /*comment!*/ ( 'asdf', { with: { type: 'json' }});
|
|
66
|
+
import /*comment!*/.meta.asdf;
|
|
67
|
+
|
|
68
|
+
// Source phase imports:
|
|
69
|
+
import source mod from './mod.wasm';
|
|
70
|
+
import.source('./mod.wasm');
|
|
71
|
+
`;
|
|
72
|
+
|
|
73
|
+
const [imports, exports] = parse(source, 'optional-sourcename');
|
|
74
|
+
|
|
75
|
+
// Returns "modထ"
|
|
76
|
+
imports[0].n
|
|
77
|
+
// Returns "mod\u1011"
|
|
78
|
+
source.slice(imports[0].s, imports[0].e);
|
|
79
|
+
// "s" = start
|
|
80
|
+
// "e" = end
|
|
81
|
+
|
|
82
|
+
// Returns "import { name } from 'mod'"
|
|
83
|
+
source.slice(imports[0].ss, imports[0].se);
|
|
84
|
+
// "ss" = statement start
|
|
85
|
+
// "se" = statement end
|
|
86
|
+
|
|
87
|
+
// Returns "{ type: 'json' }"
|
|
88
|
+
source.slice(imports[1].a, imports[1].se);
|
|
89
|
+
// "a" = attribute start, -1 for no import attributes
|
|
90
|
+
|
|
91
|
+
// Parsed import attributes are available in `at`
|
|
92
|
+
// Returns [['type', 'json']]
|
|
93
|
+
imports[1].at;
|
|
94
|
+
// Returns 'json'
|
|
95
|
+
imports[1].at[0][1];
|
|
96
|
+
|
|
97
|
+
// Returns null (no attributes)
|
|
98
|
+
imports[0].at;
|
|
99
|
+
|
|
100
|
+
// Returns "external"
|
|
101
|
+
source.slice(imports[2].s, imports[2].e);
|
|
102
|
+
|
|
103
|
+
// Returns "p"
|
|
104
|
+
source.slice(exports[0].s, exports[0].e);
|
|
105
|
+
// Returns "p"
|
|
106
|
+
source.slice(exports[0].ls, exports[0].le);
|
|
107
|
+
// Returns "q"
|
|
108
|
+
source.slice(exports[1].s, exports[1].e);
|
|
109
|
+
// Returns "q"
|
|
110
|
+
source.slice(exports[1].ls, exports[1].le);
|
|
111
|
+
|
|
112
|
+
// "ss" = export statement start (only the start is tracked, not the end)
|
|
113
|
+
// Returns "export"
|
|
114
|
+
source.slice(exports[0].ss, exports[0].ss + 6);
|
|
115
|
+
|
|
116
|
+
// Returns "'external name'"
|
|
117
|
+
source.slice(exports[2].s, exports[2].e);
|
|
118
|
+
// Returns -1
|
|
119
|
+
exports[2].ls;
|
|
120
|
+
// Returns -1
|
|
121
|
+
exports[2].le;
|
|
122
|
+
|
|
123
|
+
// Import type is provided by `t` value
|
|
124
|
+
// (1 for static, 2, for dynamic)
|
|
125
|
+
// Returns true
|
|
126
|
+
imports[2].t == 2;
|
|
127
|
+
|
|
128
|
+
// Returns "asdf" (only for string literal dynamic imports)
|
|
129
|
+
imports[2].n
|
|
130
|
+
// Returns "import /*comment!*/ ( 'asdf', { with: { type: 'json' } })"
|
|
131
|
+
source.slice(imports[3].ss, imports[3].se);
|
|
132
|
+
// Returns "'asdf'"
|
|
133
|
+
source.slice(imports[3].s, imports[3].e);
|
|
134
|
+
// Returns "( 'asdf', { with: { type: 'json' } })"
|
|
135
|
+
source.slice(imports[3].d, imports[3].se);
|
|
136
|
+
// Returns "{ with: { type: 'json' } }"
|
|
137
|
+
source.slice(imports[3].a, imports[3].se - 1);
|
|
138
|
+
|
|
139
|
+
// For non-string dynamic import expressions:
|
|
140
|
+
// - n will be undefined
|
|
141
|
+
// - a is currently -1 even if there is an import attribute
|
|
142
|
+
// - e is currently the character before the closing )
|
|
143
|
+
|
|
144
|
+
// For nested dynamic imports, the se value of the outer import is -1 as end tracking does not
|
|
145
|
+
// currently support nested dynamic immports
|
|
146
|
+
|
|
147
|
+
// import.meta is indicated by imports[3].d === -2
|
|
148
|
+
// Returns true
|
|
149
|
+
imports[4].d === -2;
|
|
150
|
+
// Returns "import /*comment!*/.meta"
|
|
151
|
+
source.slice(imports[4].s, imports[4].e);
|
|
152
|
+
// ss and se are the same for import meta
|
|
153
|
+
|
|
154
|
+
// Returns "'./mod.wasm'"
|
|
155
|
+
source.slice(imports[5].s, imports[5].e);
|
|
156
|
+
|
|
157
|
+
// Import type 4 and 5 for static and dynamic source phase
|
|
158
|
+
imports[5].t === 4;
|
|
159
|
+
imports[6].t === 5;
|
|
160
|
+
})();
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### CSP asm.js Build
|
|
164
|
+
|
|
165
|
+
The default version of the library uses Wasm and (safe) eval usage for performance and a minimal footprint.
|
|
166
|
+
|
|
167
|
+
Neither of these represent security escalation possibilities since there are no execution string injection vectors, but that can still violate existing CSP policies for applications.
|
|
168
|
+
|
|
169
|
+
For a version that works with CSP eval disabled, use the `es-module-lexer/js` build:
|
|
170
|
+
|
|
171
|
+
```js
|
|
172
|
+
import { parse } from 'es-module-lexer/js';
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Instead of Web Assembly, this uses an asm.js build which is almost as fast as the Wasm version ([see benchmarks below](#benchmarks)).
|
|
176
|
+
|
|
177
|
+
### Minimal Build
|
|
178
|
+
|
|
179
|
+
For size-sensitive embedders, the `es-module-lexer/minimal` build drops certain features to reduce the binary size. This is used for example by [es-module-shims](https://github.com/guybedford/es-module-shims):
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
import { parse } from 'es-module-lexer/minimal';
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Compared to the full build:
|
|
186
|
+
|
|
187
|
+
* `parse` returns a two-element `[imports, exports]` tuple only - the third and fourth facade and `hasModuleSyntax` booleans are dropped.
|
|
188
|
+
* Imports drop the parsed attribute list `at` (the attribute source remains recoverable via the `a` attributes index).
|
|
189
|
+
* Exports drop the statement start `ss`.
|
|
190
|
+
|
|
191
|
+
All other fields are identical to the full build. For CSP eval disabled support, the equivalent asm.js build is available as `es-module-lexer/minimal/js`.
|
|
192
|
+
|
|
193
|
+
### Import Attributes
|
|
194
|
+
|
|
195
|
+
The `a` field provides the index of the start of the `{` attributes bracket, or -1 for no attributes.
|
|
196
|
+
|
|
197
|
+
The list of attribute key and value pairs are provided on the `at` field (full build only):
|
|
198
|
+
|
|
199
|
+
```js
|
|
200
|
+
const [imports] = parse(`
|
|
201
|
+
import json from './foo.json' with { type: 'json' };
|
|
202
|
+
import './foo.css' with { type: 'css' };
|
|
203
|
+
import pkg from 'pkg' with { type: 'json', integrity: 'sha384-...' };
|
|
204
|
+
`);
|
|
205
|
+
|
|
206
|
+
// Returns [['type', 'json']]
|
|
207
|
+
imports[0].at;
|
|
208
|
+
|
|
209
|
+
// Returns [['type', 'css']]
|
|
210
|
+
imports[1].at;
|
|
211
|
+
|
|
212
|
+
// Multiple attributes
|
|
213
|
+
// Returns [['type', 'json'], ['integrity', 'sha384-...']]
|
|
214
|
+
imports[2].at;
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
The `at` field is an array of `[key, value]` tuples, or `null` if there are no attributes.
|
|
218
|
+
|
|
219
|
+
Both keys and values support escape sequences:
|
|
220
|
+
|
|
221
|
+
```js
|
|
222
|
+
const [imports] = parse(`
|
|
223
|
+
import foo from './foo.js' with { "custom-key": "value" };
|
|
224
|
+
import bar from './bar.js' with { "key\\nwith\\nnewlines": "value\\twith\\ttabs" };
|
|
225
|
+
`);
|
|
226
|
+
|
|
227
|
+
// Quoted keys are unquoted
|
|
228
|
+
// Returns [['custom-key', 'value']]
|
|
229
|
+
imports[0].at;
|
|
230
|
+
|
|
231
|
+
// Escape sequences are processed
|
|
232
|
+
// Returns [['key\nwith\nnewlines', 'value\twith\ttabs']]
|
|
233
|
+
imports[1].at;
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Escape Sequences
|
|
237
|
+
|
|
238
|
+
To handle escape sequences in specifier strings, the `.n` field of imported specifiers will be provided where possible.
|
|
239
|
+
|
|
240
|
+
For dynamic import expressions, this field will be empty if not a valid JS string.
|
|
241
|
+
|
|
242
|
+
### Facade Detection
|
|
243
|
+
|
|
244
|
+
Facade modules that only use import / export syntax can be detected via the third return value (full build only):
|
|
245
|
+
|
|
246
|
+
```js
|
|
247
|
+
const [,, facade] = parse(`
|
|
248
|
+
export * from 'external';
|
|
249
|
+
import * as ns from 'external2';
|
|
250
|
+
export { a as b } from 'external3';
|
|
251
|
+
export { ns };
|
|
252
|
+
`);
|
|
253
|
+
facade === true;
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### ESM Detection
|
|
257
|
+
|
|
258
|
+
Modules that uses ESM syntaxes can be detected via the fourth return value (full build only):
|
|
259
|
+
|
|
260
|
+
```js
|
|
261
|
+
const [,,, hasModuleSyntax] = parse(`
|
|
262
|
+
export {}
|
|
263
|
+
`);
|
|
264
|
+
hasModuleSyntax === true;
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Dynamic imports are ignored since they can be used in Non-ESM files.
|
|
268
|
+
|
|
269
|
+
```js
|
|
270
|
+
const [,,, hasModuleSyntax] = parse(`
|
|
271
|
+
import('./foo.js')
|
|
272
|
+
`);
|
|
273
|
+
hasModuleSyntax === false;
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Environment Support
|
|
277
|
+
|
|
278
|
+
Node.js 10+, and [all browsers with Web Assembly support](https://caniuse.com/#feat=wasm).
|
|
279
|
+
|
|
280
|
+
### Grammar Support
|
|
281
|
+
|
|
282
|
+
* Token state parses all line comments, block comments, strings, template strings, blocks, parens and punctuators.
|
|
283
|
+
* Division operator / regex token ambiguity is handled via backtracking checks against punctuator prefixes, including closing brace or paren backtracking.
|
|
284
|
+
* Always correctly parses valid JS source, but may parse invalid JS source without errors.
|
|
285
|
+
|
|
286
|
+
### Limitations
|
|
287
|
+
|
|
288
|
+
The lexing approach is designed to deal with the full language grammar including RegEx / division operator ambiguity through backtracking and paren / brace tracking.
|
|
289
|
+
|
|
290
|
+
Because it lexes rather than fully parses, the analysis is not a validation pass: valid JS source is always analyzed correctly, but some invalid source is accepted without an error rather than rejected. For example `export const = 1` lexes to an empty exports list instead of throwing. Callers that need to reject invalid source should run a validating parser separately.
|
|
291
|
+
|
|
292
|
+
Multiple exports per declaration (`export var a = 'asdf', q = z`) and renamed destructured exports (`export var { a: b } = asdf`) are detected correctly; earlier versions missed `q` and `b` in these forms.
|
|
293
|
+
|
|
294
|
+
### Benchmarks
|
|
295
|
+
|
|
296
|
+
Benchmarks can be run with `npm run bench`.
|
|
297
|
+
|
|
298
|
+
Current results for a high spec machine:
|
|
299
|
+
|
|
300
|
+
#### Wasm Build
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
Module load time
|
|
304
|
+
> 5ms
|
|
305
|
+
Cold Run, All Samples
|
|
306
|
+
test/samples/*.js (3123 KiB)
|
|
307
|
+
> 18ms
|
|
308
|
+
|
|
309
|
+
Warm Runs (average of 25 runs)
|
|
310
|
+
test/samples/angular.js (739 KiB)
|
|
311
|
+
> 3ms
|
|
312
|
+
test/samples/angular.min.js (188 KiB)
|
|
313
|
+
> 1ms
|
|
314
|
+
test/samples/d3.js (508 KiB)
|
|
315
|
+
> 3ms
|
|
316
|
+
test/samples/d3.min.js (274 KiB)
|
|
317
|
+
> 2ms
|
|
318
|
+
test/samples/magic-string.js (35 KiB)
|
|
319
|
+
> 0ms
|
|
320
|
+
test/samples/magic-string.min.js (20 KiB)
|
|
321
|
+
> 0ms
|
|
322
|
+
test/samples/rollup.js (929 KiB)
|
|
323
|
+
> 4.32ms
|
|
324
|
+
test/samples/rollup.min.js (429 KiB)
|
|
325
|
+
> 2.16ms
|
|
326
|
+
|
|
327
|
+
Warm Runs, All Samples (average of 25 runs)
|
|
328
|
+
test/samples/*.js (3123 KiB)
|
|
329
|
+
> 14.16ms
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
#### JS Build (asm.js)
|
|
333
|
+
|
|
334
|
+
```
|
|
335
|
+
Module load time
|
|
336
|
+
> 2ms
|
|
337
|
+
Cold Run, All Samples
|
|
338
|
+
test/samples/*.js (3123 KiB)
|
|
339
|
+
> 34ms
|
|
340
|
+
|
|
341
|
+
Warm Runs (average of 25 runs)
|
|
342
|
+
test/samples/angular.js (739 KiB)
|
|
343
|
+
> 3ms
|
|
344
|
+
test/samples/angular.min.js (188 KiB)
|
|
345
|
+
> 1ms
|
|
346
|
+
test/samples/d3.js (508 KiB)
|
|
347
|
+
> 3ms
|
|
348
|
+
test/samples/d3.min.js (274 KiB)
|
|
349
|
+
> 2ms
|
|
350
|
+
test/samples/magic-string.js (35 KiB)
|
|
351
|
+
> 0ms
|
|
352
|
+
test/samples/magic-string.min.js (20 KiB)
|
|
353
|
+
> 0ms
|
|
354
|
+
test/samples/rollup.js (929 KiB)
|
|
355
|
+
> 5ms
|
|
356
|
+
test/samples/rollup.min.js (429 KiB)
|
|
357
|
+
> 3.04ms
|
|
358
|
+
|
|
359
|
+
Warm Runs, All Samples (average of 25 runs)
|
|
360
|
+
test/samples/*.js (3123 KiB)
|
|
361
|
+
> 17.12ms
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Building
|
|
365
|
+
|
|
366
|
+
This project uses [Chomp](https://chompbuild.com) for building.
|
|
367
|
+
|
|
368
|
+
With Chomp installed, download the WASI SDK 12.0 from https://github.com/WebAssembly/wasi-sdk/releases/tag/wasi-sdk-12.
|
|
369
|
+
|
|
370
|
+
- [Linux](https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz)
|
|
371
|
+
- [Windows (MinGW)](https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-mingw.tar.gz)
|
|
372
|
+
- [macOS](https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz)
|
|
373
|
+
|
|
374
|
+
Locate the WASI-SDK as a sibling folder, or customize the path via the `WASI_PATH` environment variable.
|
|
375
|
+
|
|
376
|
+
Emscripten emsdk is also assumed to be a sibling folder or via the `EMSDK_PATH` environment variable.
|
|
377
|
+
|
|
378
|
+
Example setup:
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
git clone https://github.com:guybedford/es-module-lexer
|
|
382
|
+
git clone https://github.com/emscripten-core/emsdk
|
|
383
|
+
cd emsdk
|
|
384
|
+
git checkout 1.40.1-fastcomp
|
|
385
|
+
./emsdk install 1.40.1-fastcomp
|
|
386
|
+
cd ..
|
|
387
|
+
wget https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-linux.tar.gz
|
|
388
|
+
gunzip wasi-sdk-12.0-linux.tar.gz
|
|
389
|
+
tar -xf wasi-sdk-12.0-linux.tar
|
|
390
|
+
mv wasi-sdk-12.0-linux.tar wasi-sdk-12.0
|
|
391
|
+
cargo install chompbuild
|
|
392
|
+
cd es-module-lexer
|
|
393
|
+
chomp test
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
For the `asm.js` build, git clone `emsdk` from is assumed to be a sibling folder as well.
|
|
397
|
+
|
|
398
|
+
### License
|
|
399
|
+
|
|
400
|
+
MIT
|
|
401
|
+
|
|
402
|
+
[actions-image]: https://github.com/guybedford/es-module-lexer/actions/workflows/build.yml/badge.svg
|
|
403
|
+
[actions-url]: https://github.com/guybedford/es-module-lexer/actions/workflows/build.yml
|