diff --git a/lib/esbuild.config.js b/lib/esbuild.config.js index c4b0c55..571b433 100644 --- a/lib/esbuild.config.js +++ b/lib/esbuild.config.js @@ -2,7 +2,7 @@ import path, { resolve } from 'path'; import { fileURLToPath } from 'url'; import { build, context, analyzeMetafile } from 'esbuild'; -import * as dotenv from 'dotenv' +import * as dotenv from 'dotenv'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -13,7 +13,7 @@ const SRC = resolve(__dirname, 'src'); dotenv.config({ path: `${ROOT}/.env` -}) +}); const BUILD = process.env.BUILD || 'production'; const DEBUG = process.env.DEBUG === 'true'; @@ -27,7 +27,7 @@ const config = { external: ['@hcaptcha/types'], tsconfig: 'tsconfig.json', define: { - 'process.env.SENTRY_DSN_TOKEN': JSON.stringify(SENTRY), + 'process.env.SENTRY_DSN_TOKEN': JSON.stringify(SENTRY), }, @@ -46,36 +46,42 @@ const config = { if (WATCH) { - const ctx = await context({ - ...config, - format: 'esm', - outfile: resolve(DIST, 'index.mjs'), - treeShaking: true - }); - await ctx.watch(); + const ctx = await context({ + ...config, + format: 'esm', + outfile: resolve(DIST, 'index.mjs'), + treeShaking: true, + target: [ + 'es6' + ] + }); + await ctx.watch(); } else { - const resultESM = await build({ - ...config, - format: 'esm', - outfile: resolve(DIST, 'index.mjs'), - treeShaking: true - }); + const resultESM = await build({ + ...config, + format: 'esm', + outfile: resolve(DIST, 'index.mjs'), + treeShaking: true, + target: [ + 'es6' + ] + }); - const resultCJS = await build({ - ...config, - format: 'cjs', - outfile: resolve(DIST, 'index.cjs'), - treeShaking: true - }); + const resultCJS = await build({ + ...config, + format: 'cjs', + outfile: resolve(DIST, 'index.cjs'), + treeShaking: true + }); - if (DEBUG) { - const analyzeESM = await analyzeMetafile(resultESM.metafile, { - verbose: false - }); - const analyzeCJS = await analyzeMetafile(resultCJS.metafile, { - verbose: false - }); - console.log(analyzeESM); - console.log(analyzeCJS); - } + if (DEBUG) { + const analyzeESM = await analyzeMetafile(resultESM.metafile, { + verbose: false + }); + const analyzeCJS = await analyzeMetafile(resultCJS.metafile, { + verbose: false + }); + console.log(analyzeESM); + console.log(analyzeCJS); + } } diff --git a/package.json b/package.json index bb0a04c..2d5d858 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@hcaptcha/loader", "description": "This is a JavaScript library to easily configure the loading of the hCaptcha JS client SDK with built-in error handling.", - "version": "1.1.2", + "version": "1.1.3", "author": "hCaptcha team and contributors", "license": "MIT", "keywords": [