Skip to content

Commit 80eed0e

Browse files
authored
Merge pull request #36 from microlinkhq/dependabot/npm_and_yarn/microlink/mql-0.15.1
build(deps): bump @microlink/mql from 0.14.2 to 0.15.1
2 parents 4e8713d + 0acb0a0 commit 80eed0e

14 files changed

Lines changed: 158 additions & 145 deletions

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,4 @@ coverage
3535
.env
3636
.envrc
3737
stats.html
38-
src/node.mjs
39-
lightweight/index.js
40-
lightweight/index-bundled.d.ts
38+
dist/index.js

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
}
5959
</script>
6060
<script type="module">
61-
import microlink from './lightweight/index.js'
61+
import microlink from './dist/index.js'
6262

6363
function getBrowser() {
6464
var ua=navigator.userAgent,tem,M=ua.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || [];

lightweight/package.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

package.json

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
"description": "Browser functions as Service. Interacting with browser pages, remotely.",
44
"homepage": "https://function.microlink.io",
55
"version": "0.2.2",
6-
"types": "lightweight/index.d.ts",
6+
"types": "src/index.d.ts",
77
"exports": {
8-
"require": "./src/node.js",
9-
"default": "./lightweight/index.js"
8+
"types": "./src/index.d.ts",
9+
"require": "./src/index.js",
10+
"import": "./src/index.mjs",
11+
"default": "./src/index.mjs"
1012
},
1113
"author": {
1214
"email": "josefrancisco.verdu@gmail.com",
@@ -31,8 +33,8 @@
3133
"serverless"
3234
],
3335
"dependencies": {
34-
"@microlink/mql": "~0.14.0",
35-
"base64-url": "~2.3.3"
36+
"@microlink/mql": "~0.15.1",
37+
"lz-ts": "~1.1.2"
3638
},
3739
"devDependencies": {
3840
"@commitlint/cli": "latest",
@@ -54,26 +56,22 @@
5456
"puppeteer-core": "latest",
5557
"rollup": "latest",
5658
"rollup-plugin-filesize": "latest",
57-
"rollup-plugin-rewrite": "latest",
58-
"rollup-plugin-visualizer": "latest",
5959
"simple-git-hooks": "latest",
6060
"standard": "latest",
6161
"standard-version": "latest",
62-
"stream-to-promise": "latest",
62+
"tinyspawn": "latest",
6363
"tsd": "latest"
6464
},
6565
"engines": {
6666
"node": ">= 18"
6767
},
6868
"files": [
69-
"lightweight",
70-
"src/factory.js",
71-
"src/node.js"
69+
"src"
7270
],
7371
"scripts": {
7472
"build": "rollup -c rollup.config.js --bundleConfigAsCjs",
7573
"clean": "rm -rf node_modules",
76-
"clean:build": "rm -rf lightweight/index.js",
74+
"clean:build": "rm -rf dist/index.js",
7775
"contributors": "(npx git-authors-cli && npx finepack && git add package.json && git commit -m 'build: contributors' --no-verify) || true",
7876
"dev": "npm run build -- -w",
7977
"lint": "standard && tsd",
@@ -88,10 +86,6 @@
8886
},
8987
"license": "MIT",
9088
"ava": {
91-
"files": [
92-
"test/**/*",
93-
"!test/clients.mjs"
94-
],
9589
"timeout": "1m"
9690
},
9791
"commitlint": {
@@ -119,11 +113,18 @@
119113
},
120114
"standard": {
121115
"ignore": [
122-
"lightweight/index.js",
123-
"src/node.mjs"
116+
"dist"
124117
]
125118
},
126119
"tsd": {
120+
"compilerOptions": {
121+
"baseUrl": ".",
122+
"paths": {
123+
"@microlink/function": [
124+
"./src/index.d.ts"
125+
]
126+
}
127+
},
127128
"directory": "test"
128129
}
129130
}

rollup.config.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import nodeResolve from '@rollup/plugin-node-resolve'
2-
import { visualizer } from 'rollup-plugin-visualizer'
32
import commonjs from '@rollup/plugin-commonjs'
43
import filesize from 'rollup-plugin-filesize'
54
import replace from '@rollup/plugin-replace'
@@ -23,24 +22,22 @@ const build = ({ input, output, plugins = [], compress }) => {
2322
comments: false
2423
}
2524
}),
26-
filesize(),
27-
visualizer()
28-
]
25+
filesize()
26+
].filter(Boolean)
2927
}
3028
}
3129

3230
const builds = [
33-
/* This build is just for testing using ESM interface */
34-
build({
35-
input: './src/node.js',
36-
output: { file: 'src/node.mjs', format: 'es' },
37-
plugins: [commonjs()]
38-
}),
3931
build({
40-
compress: true,
41-
input: 'src/lightweight.mjs',
42-
output: { file: 'lightweight/index.js', format: 'es' },
43-
plugins: [nodeResolve()]
32+
compress: false,
33+
input: 'src/index.js',
34+
output: { file: 'dist/index.js', format: 'es' },
35+
plugins: [
36+
nodeResolve({
37+
mainFields: ['browser', 'module', 'main']
38+
}),
39+
commonjs({ strictRequires: 'auto' })
40+
]
4441
})
4542
]
4643

File renamed without changes.

src/index.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict'
2+
3+
const mql = require('@microlink/mql')
4+
5+
let toCompress
6+
7+
try {
8+
const { promisify } = require('util')
9+
const { brotliCompress } = require('zlib')
10+
const compress = promisify(brotliCompress)
11+
toCompress = async code =>
12+
`br#${(await compress(code.toString())).toString('base64url')}`
13+
} catch {
14+
const { compressToURI } = require('lz-ts')
15+
toCompress = code => Promise.resolve(`lz#${compressToURI(code.toString())}`)
16+
}
17+
18+
const fn = (code, mqlOpts, gotOpts) => {
19+
const compressed = toCompress(code)
20+
21+
return async (url, opts) => {
22+
const { data } = await mql(
23+
url,
24+
{
25+
function: await compressed,
26+
meta: false,
27+
...mqlOpts,
28+
...opts
29+
},
30+
gotOpts
31+
)
32+
33+
return data.function
34+
}
35+
}
36+
37+
fn.compress = toCompress
38+
fn.mql = mql
39+
fn.version = require('../package.json').version
40+
41+
module.exports = fn

src/index.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createRequire } from 'module'
2+
3+
const require = createRequire(import.meta.url)
4+
const fn = require('./index.js')
5+
6+
export const compress = fn.compress
7+
export const mql = fn.mql
8+
export const version = fn.version
9+
10+
export default fn

src/lightweight.mjs

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/node.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)