Skip to content

Commit 537bc1d

Browse files
authored
fix(browser-support): add target to esbuild options (#19)
1 parent 2c1e320 commit 537bc1d

File tree

2 files changed

+39
-33
lines changed

2 files changed

+39
-33
lines changed

lib/esbuild.config.js

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path, { resolve } from 'path';
22
import { fileURLToPath } from 'url';
33

44
import { build, context, analyzeMetafile } from 'esbuild';
5-
import * as dotenv from 'dotenv'
5+
import * as dotenv from 'dotenv';
66

77
const __filename = fileURLToPath(import.meta.url);
88
const __dirname = path.dirname(__filename);
@@ -13,7 +13,7 @@ const SRC = resolve(__dirname, 'src');
1313

1414
dotenv.config({
1515
path: `${ROOT}/.env`
16-
})
16+
});
1717

1818
const BUILD = process.env.BUILD || 'production';
1919
const DEBUG = process.env.DEBUG === 'true';
@@ -27,7 +27,7 @@ const config = {
2727
external: ['@hcaptcha/types'],
2828
tsconfig: 'tsconfig.json',
2929
define: {
30-
'process.env.SENTRY_DSN_TOKEN': JSON.stringify(SENTRY),
30+
'process.env.SENTRY_DSN_TOKEN': JSON.stringify(SENTRY),
3131

3232
},
3333

@@ -46,36 +46,42 @@ const config = {
4646

4747

4848
if (WATCH) {
49-
const ctx = await context({
50-
...config,
51-
format: 'esm',
52-
outfile: resolve(DIST, 'index.mjs'),
53-
treeShaking: true
54-
});
55-
await ctx.watch();
49+
const ctx = await context({
50+
...config,
51+
format: 'esm',
52+
outfile: resolve(DIST, 'index.mjs'),
53+
treeShaking: true,
54+
target: [
55+
'es6'
56+
]
57+
});
58+
await ctx.watch();
5659
} else {
57-
const resultESM = await build({
58-
...config,
59-
format: 'esm',
60-
outfile: resolve(DIST, 'index.mjs'),
61-
treeShaking: true
62-
});
60+
const resultESM = await build({
61+
...config,
62+
format: 'esm',
63+
outfile: resolve(DIST, 'index.mjs'),
64+
treeShaking: true,
65+
target: [
66+
'es6'
67+
]
68+
});
6369

64-
const resultCJS = await build({
65-
...config,
66-
format: 'cjs',
67-
outfile: resolve(DIST, 'index.cjs'),
68-
treeShaking: true
69-
});
70+
const resultCJS = await build({
71+
...config,
72+
format: 'cjs',
73+
outfile: resolve(DIST, 'index.cjs'),
74+
treeShaking: true
75+
});
7076

71-
if (DEBUG) {
72-
const analyzeESM = await analyzeMetafile(resultESM.metafile, {
73-
verbose: false
74-
});
75-
const analyzeCJS = await analyzeMetafile(resultCJS.metafile, {
76-
verbose: false
77-
});
78-
console.log(analyzeESM);
79-
console.log(analyzeCJS);
80-
}
77+
if (DEBUG) {
78+
const analyzeESM = await analyzeMetafile(resultESM.metafile, {
79+
verbose: false
80+
});
81+
const analyzeCJS = await analyzeMetafile(resultCJS.metafile, {
82+
verbose: false
83+
});
84+
console.log(analyzeESM);
85+
console.log(analyzeCJS);
86+
}
8187
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@hcaptcha/loader",
33
"description": "This is a JavaScript library to easily configure the loading of the hCaptcha JS client SDK with built-in error handling.",
4-
"version": "1.1.2",
4+
"version": "1.1.3",
55
"author": "hCaptcha team and contributors",
66
"license": "MIT",
77
"keywords": [

0 commit comments

Comments
 (0)