Skip to content

Commit 2806fe4

Browse files
authored
fix: add special target for Cloudflare Workers (#151)
* fix: create a new package for workers * add workers package for datadog and lightstep too * add package for stdout * remove flush * make sure data is sent from the examples * unify packages for stdout * unify packages for honeycomb * update wrangler * unify packages for lightstep * unify packages for datadog * fix tests
1 parent 790c9af commit 2806fe4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+7096
-343
lines changed

js/esbuild/esbuild.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,21 @@ program
6363
.option('-p, --platform <string>')
6464
.option('-f, --format <string>')
6565
.option('-g, --generateTypes')
66+
.option('-w, --workerd')
6667
program.parse();
6768

6869
const options = program.opts();
6970

70-
// conditional logic for polyfilling deno
71-
const plugins = [
71+
// conditional logic for Cloudflare Workers
72+
const plugins = options.workerd ? [] : [
7273
wasmPlugin,
7374
]
7475

76+
// conditional logic for Cloudflare Workers
77+
const loader = options.workerd ? {
78+
'.wasm': 'copy',
79+
} : {}
80+
7581
esbuild.build({
7682
entryPoints: [options.entrypoint],
7783
bundle: options.bundle,
@@ -80,8 +86,6 @@ esbuild.build({
8086
outfile: options.outfile,
8187
platform: options.platform,
8288
format: options.format,
83-
// loader: {
84-
// '.data': 'binary'
85-
// },
89+
loader,
8690
plugins,
8791
})

js/packages/observe-sdk-datadog/package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,25 @@
88
"main": "./dist/cjs/index.js",
99
"module": "./dist/esm/index.js",
1010
"types": "./dist/types/index.d.ts",
11+
"exports": {
12+
"workerd": "./dist/workerd/index.js",
13+
"default": {
14+
"types": "./dist/types/index.d.ts",
15+
"import": "./dist/esm/index.js",
16+
"require": "./dist/cjs/index.js"
17+
}
18+
},
1119
"scripts": {
1220
"build:esm": "node ../../esbuild/esbuild.js -b -e ./index.js -o ../observe-sdk-datadog/dist/esm/index.js -p browser -f esm",
1321
"build:cjs": "node ../../esbuild/esbuild.js -b -e ./index.js -o ../observe-sdk-datadog/dist/cjs/index.js -p browser -f cjs",
22+
"build:workerd": "node ../../esbuild/esbuild.js -b -e ./index.js -o ./dist/workerd/index.js -p browser -f esm --workerd",
1423
"build:types": "tsc -b",
15-
"build": "npm run build:esm && npm run build:cjs && npm run build:types",
24+
"build": "npm run build:esm && npm run build:cjs && npm run build:workerd && npm run build:types",
1625
"build:web-test": "node ../../esbuild/esbuild.js -b -e ./test/web/index.js -o ./test/web/build.js -p browser",
1726
"test:node": "node test/node/index.js",
1827
"test:deno": "deno run -A test/deno/index.ts",
19-
"test:web": "npm run build:web-test && npx serve ./test/web"
28+
"test:web": "npm run build:web-test && npx serve ./test/web",
29+
"test:workerd": "npx wrangler dev -c ./test/workerd/wrangler.toml"
2030
},
2131
"keywords": [
2232
"dylibso",

js/packages/observe-sdk-datadog/test/node/package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/packages/observe-sdk-datadog/test/node/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@
77
"test": "echo \"Error: no test specified\" && exit 1"
88
},
99
"author": "",
10-
"license": "ISC"
10+
"license": "ISC",
11+
"dependencies": {
12+
"@dylibso/observe-sdk-datadog": "file:../.."
13+
}
1114
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = tab
6+
tab_width = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.yml]
13+
indent_style = space
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
# Logs
2+
3+
logs
4+
_.log
5+
npm-debug.log_
6+
yarn-debug.log*
7+
yarn-error.log*
8+
lerna-debug.log*
9+
.pnpm-debug.log*
10+
11+
# Diagnostic reports (https://nodejs.org/api/report.html)
12+
13+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
14+
15+
# Runtime data
16+
17+
pids
18+
_.pid
19+
_.seed
20+
\*.pid.lock
21+
22+
# Directory for instrumented libs generated by jscoverage/JSCover
23+
24+
lib-cov
25+
26+
# Coverage directory used by tools like istanbul
27+
28+
coverage
29+
\*.lcov
30+
31+
# nyc test coverage
32+
33+
.nyc_output
34+
35+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
36+
37+
.grunt
38+
39+
# Bower dependency directory (https://bower.io/)
40+
41+
bower_components
42+
43+
# node-waf configuration
44+
45+
.lock-wscript
46+
47+
# Compiled binary addons (https://nodejs.org/api/addons.html)
48+
49+
build/Release
50+
51+
# Dependency directories
52+
53+
node_modules/
54+
jspm_packages/
55+
56+
# Snowpack dependency directory (https://snowpack.dev/)
57+
58+
web_modules/
59+
60+
# TypeScript cache
61+
62+
\*.tsbuildinfo
63+
64+
# Optional npm cache directory
65+
66+
.npm
67+
68+
# Optional eslint cache
69+
70+
.eslintcache
71+
72+
# Optional stylelint cache
73+
74+
.stylelintcache
75+
76+
# Microbundle cache
77+
78+
.rpt2_cache/
79+
.rts2_cache_cjs/
80+
.rts2_cache_es/
81+
.rts2_cache_umd/
82+
83+
# Optional REPL history
84+
85+
.node_repl_history
86+
87+
# Output of 'npm pack'
88+
89+
\*.tgz
90+
91+
# Yarn Integrity file
92+
93+
.yarn-integrity
94+
95+
# dotenv environment variable files
96+
97+
.env
98+
.env.development.local
99+
.env.test.local
100+
.env.production.local
101+
.env.local
102+
103+
# parcel-bundler cache (https://parceljs.org/)
104+
105+
.cache
106+
.parcel-cache
107+
108+
# Next.js build output
109+
110+
.next
111+
out
112+
113+
# Nuxt.js build / generate output
114+
115+
.nuxt
116+
dist
117+
118+
# Gatsby files
119+
120+
.cache/
121+
122+
# Comment in the public line in if your project uses Gatsby and not Next.js
123+
124+
# https://nextjs.org/blog/next-9-1#public-directory-support
125+
126+
# public
127+
128+
# vuepress build output
129+
130+
.vuepress/dist
131+
132+
# vuepress v2.x temp and cache directory
133+
134+
.temp
135+
.cache
136+
137+
# Docusaurus cache and generated files
138+
139+
.docusaurus
140+
141+
# Serverless directories
142+
143+
.serverless/
144+
145+
# FuseBox cache
146+
147+
.fusebox/
148+
149+
# DynamoDB Local files
150+
151+
.dynamodb/
152+
153+
# TernJS port file
154+
155+
.tern-port
156+
157+
# Stores VSCode versions used for testing VSCode extensions
158+
159+
.vscode-test
160+
161+
# yarn v2
162+
163+
.yarn/cache
164+
.yarn/unplugged
165+
.yarn/build-state.yml
166+
.yarn/install-state.gz
167+
.pnp.\*
168+
169+
# wrangler project
170+
171+
.dev.vars
172+
.wrangler/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"printWidth": 140,
3+
"singleQuote": true,
4+
"semi": true,
5+
"useTabs": true
6+
}

0 commit comments

Comments
 (0)