-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
147 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"main": "index.js", | ||
"type": "module" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
{ | ||
"name": "@microlink/function", | ||
"homepage": "https://github.com/microlinkhq/function#readme", | ||
"url": "https://function.microlink.io", | ||
"description": "Browser functions as Service. Interacting with browser pages, remotely.", | ||
"homepage": "https://function.microlink.io", | ||
"version": "0.1.7", | ||
"main": "src/node.js", | ||
"browser": "src/browser.js", | ||
"exports": { | ||
".": { | ||
"import": "./lightweight/index.js", | ||
"require": "./src/node.js" | ||
} | ||
}, | ||
"author": { | ||
"name": "Kiko Beats", | ||
"email": "[email protected]", | ||
"name": "Kiko Beats", | ||
"url": "https://kikobeats.com" | ||
}, | ||
"repository": { | ||
|
@@ -29,47 +35,48 @@ | |
"serverless" | ||
], | ||
"dependencies": { | ||
"@microlink/mql": "~0.11.4", | ||
"@microlink/mql": "~0.11.5", | ||
"base64-url": "~2.3.3" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "latest", | ||
"@rollup/plugin-node-resolve": "latest", | ||
"@rollup/plugin-replace": "latest", | ||
"abort-controller": "latest", | ||
"@rollup/plugin-terser": "latest", | ||
"ava": "latest", | ||
"c8": "latest", | ||
"conventional-github-releaser": "latest", | ||
"node-fetch": "2", | ||
"execa": "latest", | ||
"npm-check-updates": "latest", | ||
"rollup": "latest", | ||
"rollup-plugin-filesize": "latest", | ||
"rollup-plugin-shim": "latest", | ||
"rollup-plugin-terser": "latest", | ||
"rollup-plugin-visualizer": "latest" | ||
}, | ||
"engines": { | ||
"node": ">= 12" | ||
"node": ">= 18" | ||
}, | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"scripts": { | ||
"build": "rollup -c rollup.config.js", | ||
"postversion": "pnpm run build", | ||
"build": "rollup -c rollup.config.js --bundleConfigAsCjs", | ||
"dev": "npm run build -- -w", | ||
"postversion": "pnpm run build", | ||
"test": "c8 ava --verbose" | ||
}, | ||
"license": "MIT", | ||
"ava": { | ||
"files": [ | ||
"test/**/*", | ||
"!test/browser-globals.js", | ||
"!test/clients.js" | ||
"!test/clients.mjs" | ||
], | ||
"timeout": "1m" | ||
}, | ||
"umd:main": "dist/microlink-function.js", | ||
"unpkg": "dist/microlink-function.js" | ||
"standard": { | ||
"ignore": [ | ||
"dist", | ||
"lightweight/index.js" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,51 @@ | ||
import nodeResolve from '@rollup/plugin-node-resolve' | ||
import visualizer from 'rollup-plugin-visualizer' | ||
import { visualizer } from 'rollup-plugin-visualizer' | ||
import commonjs from '@rollup/plugin-commonjs' | ||
import replace from '@rollup/plugin-replace' | ||
import { terser } from 'rollup-plugin-terser' | ||
import filesize from 'rollup-plugin-filesize' | ||
import replace from '@rollup/plugin-replace' | ||
import terser from '@rollup/plugin-terser' | ||
|
||
const build = ({ format, exports, input } = {}) => { | ||
const base = ({ file, compress = false }) => ({ | ||
const build = ({ input, output, plugins = [], compress }) => { | ||
return { | ||
input, | ||
output: { | ||
exports, | ||
name: 'microlink', | ||
format, | ||
file, | ||
sourcemap: true | ||
}, | ||
output, | ||
plugins: [ | ||
nodeResolve({ | ||
mainFields: ['browser', 'module', 'main'] | ||
}), | ||
replace({ | ||
__VERSION__: require('./package.json').version, | ||
__MQL_VERSION__: require('@microlink/mql').version | ||
values: { | ||
"require('../package.json').version": "'__MFN_VERSION__'", | ||
__MFN_VERSION__: require('./package.json').version | ||
} | ||
}), | ||
commonjs(), | ||
compress && terser(), | ||
...plugins, | ||
compress && | ||
terser({ | ||
format: { | ||
comments: false | ||
} | ||
}), | ||
filesize(), | ||
visualizer() | ||
] | ||
}) | ||
|
||
return [ | ||
base({ file: 'dist/microlink-function.js', compress: false }), | ||
base({ file: 'dist/microlink-function.min.js', compress: true }) | ||
] | ||
} | ||
} | ||
|
||
export default build({ | ||
format: 'umd', | ||
input: './src/browser.js' | ||
}) | ||
const builds = [ | ||
/* This build is just for testing using ESM interface */ | ||
build({ | ||
input: './src/node.js', | ||
output: { file: 'dist/node.mjs', format: 'es' }, | ||
plugins: [ | ||
commonjs() | ||
] | ||
}), | ||
build({ | ||
compress: true, | ||
input: 'src/lightweight.mjs', | ||
output: { file: 'lightweight/index.js', format: 'es' }, | ||
plugins: [ | ||
nodeResolve() | ||
] | ||
}) | ||
] | ||
|
||
export default builds |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import mql from '@microlink/mql' | ||
|
||
const fn = (code, mqlOpts, gotOpts) => async (url, opts) => { | ||
const { data } = await mql( | ||
url, | ||
{ | ||
function: code.toString(), | ||
meta: false, | ||
...mqlOpts, | ||
...opts | ||
}, | ||
gotOpts | ||
) | ||
|
||
return data.function | ||
} | ||
|
||
fn.mql = mql | ||
fn.render = mql.render | ||
fn.version = require('../package.json').version | ||
|
||
export default fn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.