Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,3 @@ functions:
url: example.com/myfunction
method: GET
```

### Web Assembly

The plugin can upload and bind WASM to execute in your worker. The easiest way to do this is to use the --template cloudflare-workers-rust when generating a project. The template includes a Rust create folder setup with wasm-pack, a webpack script for adding the generated javascript into your project, and the yml file settings to upload the wasm file itself.

```yaml
functions:
myfunction:
name: myfunction
webpack: true
script: handlers/myfunctionhandler
resources:
wasm:
- variable: WASM
filename: rust/pkg/wasm_bg.wasm
events:
- http:
url: example.com/myfunction
method: GET
```
4 changes: 1 addition & 3 deletions deploy/lib/singlescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
const sdk = require("../../provider/sdk");
const { generateCode, generateWASM } = require("./workerScript");
const { generateCode } = require("./workerScript");
const BB = require("bluebird");
const webpack = require("../../utils/webpack");
const cf = require("cloudflare-workers-toolkit");
Expand Down Expand Up @@ -82,7 +82,6 @@ module.exports = {
accountId: this.provider.config.accountId,
zoneId,
script: scriptContents,
wasm: generateWASM(functionObject),
bindings
});

Expand All @@ -99,7 +98,6 @@ module.exports = {
}

return {
namespaceResponse,
workerScriptResponse,
routesResponse,
isMultiScript: false
Expand Down
17 changes: 1 addition & 16 deletions deploy/lib/workerScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,6 @@ const generateCode = (serverless, functionObject) => {
return fs.readFileSync(script).toString();
};

/**
* Builds the list of wasm objects for script deployment
* @param {} functionObject
*/
const generateWASM = (functionObject) => {
let wasm = [];
if (functionObject && functionObject.resources && functionObject.resources.wasm) {
functionObject.resources.wasm.map((w) => {
wasm.push(w.file);
})
}
return wasm;
}

module.exports = {
generateCode,
generateWASM
generateCode
};
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-cloudflare-workers",
"version": "1.2.0",
"version": "1.1.1",
"description": "serverless cloudflare workers ",
"main": "index.js",
"scripts": {
Expand All @@ -22,7 +22,7 @@
],
"dependencies": {
"bluebird": "^3.4.7",
"cloudflare-workers-toolkit": "^0.1.0",
"cloudflare-workers-toolkit": "0.0.11",
"fs-extra": "^7.0.1",
"node-fetch": "^2.3.0",
"webpack": "^4.25.1"
Expand Down
16 changes: 1 addition & 15 deletions shared/multiscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
const cf = require("cloudflare-workers-toolkit");
const path = require("path");
const { generateCode, generateWASM } = require("../deploy/lib/workerScript");
const { generateCode } = require("../deploy/lib/workerScript");

module.exports = {
getRoutes(events) {
Expand Down Expand Up @@ -56,18 +55,6 @@ module.exports = {
bindings = bindings.concat(namespaceBindings);
}

if (resources && resources.wasm) {
let wasmBindings = resources.wasm.map(function(wasm) {
return {
name: wasm.variable,
type: 'wasm_module',
part: path.basename(wasm.file, path.extname(wasm.file))
}
});

bindings = bindings.concat(wasmBindings);
}

// Get Environment Variables
let envVars = Object.assign({}, provider.environment);
envVars = Object.assign(envVars, functionObject.environment);
Expand Down Expand Up @@ -100,7 +87,6 @@ module.exports = {
accountId,
name: functionObject.name,
script: contents,
wasm: generateWASM(functionObject),
bindings
})

Expand Down