diff --git a/.changeset/forty-toes-stare.md b/.changeset/forty-toes-stare.md new file mode 100644 index 000000000..24fc716c7 --- /dev/null +++ b/.changeset/forty-toes-stare.md @@ -0,0 +1,6 @@ +--- +'@segment/analytics-consent-tools': patch +'@segment/analytics-consent-wrapper-onetrust': patch +--- + +Support older browsers diff --git a/package.json b/package.json index 64dee97c1..9d92d092f 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "prettier": "^2.6.2", "ts-jest": "^28.0.4", "ts-node": "^10.8.0", - "turbo": "^1.3.1", + "turbo": "^1.10.14", "typescript": "^4.7.0", "webpack": "^5.76.0", "webpack-dev-server": "^4.15.1" diff --git a/packages/config-webpack/package.json b/packages/config-webpack/package.json index c243c7314..fabafc794 100644 --- a/packages/config-webpack/package.json +++ b/packages/config-webpack/package.json @@ -11,6 +11,7 @@ "@types/circular-dependency-plugin": "^5", "babel-loader": "^8.0.0", "circular-dependency-plugin": "^5.2.2", + "ecma-version-validator-webpack-plugin": "^1.2.1", "terser-webpack-plugin": "^5.1.4", "webpack": "^5.76.0", "webpack-cli": "^4.8.0", diff --git a/packages/config-webpack/webpack.config.common.js b/packages/config-webpack/webpack.config.common.js index 4710464c2..d69005c4d 100644 --- a/packages/config-webpack/webpack.config.common.js +++ b/packages/config-webpack/webpack.config.common.js @@ -1,5 +1,8 @@ const TerserPlugin = require('terser-webpack-plugin') const CircularDependencyPlugin = require('circular-dependency-plugin') +const { + ECMAVersionValidatorPlugin, +} = require('ecma-version-validator-webpack-plugin') const isProd = process.env.NODE_ENV === 'production' const isWatch = process.env.WATCH === 'true' @@ -15,6 +18,7 @@ module.exports = { devtool: 'source-map', stats: isWatch ? 'errors-warnings' : 'normal', mode: isProd ? 'production' : 'development', + target: ['web', 'es5'], // target es5 for ie11 support (generates module boilerplate in es5) module: { rules: [ { @@ -37,7 +41,6 @@ module.exports = { }, }, ], - exclude: /node_modules/, }, ], }, @@ -67,5 +70,6 @@ module.exports = { new CircularDependencyPlugin({ failOnError: true, }), + new ECMAVersionValidatorPlugin({ ecmaVersion: 5 }), // ensure our js bundle only contains syntax supported in ie11. This does not check polyfills. ], } diff --git a/packages/consent/consent-tools/tsconfig.json b/packages/consent/consent-tools/tsconfig.json index fb6cefa38..1af879200 100644 --- a/packages/consent/consent-tools/tsconfig.json +++ b/packages/consent/consent-tools/tsconfig.json @@ -3,7 +3,7 @@ "exclude": ["node_modules", "dist"], "compilerOptions": { "module": "ESNext", // es6 modules - "target": "ESNext", // assume that consumers will be using webpack, so don't down-compile + "target": "ES2020", // don't down-compile *too much* -- if users are using webpack, they can always transpile this library themselves "lib": ["ES2020", "DOM", "DOM.Iterable"], // assume that consumers will be polyfilling at least down to es2020 "moduleResolution": "node", "resolveJsonModule": true diff --git a/packages/consent/consent-wrapper-onetrust/README.md b/packages/consent/consent-wrapper-onetrust/README.md index 8d317d69b..847c1785a 100644 --- a/packages/consent/consent-wrapper-onetrust/README.md +++ b/packages/consent/consent-wrapper-onetrust/README.md @@ -101,13 +101,13 @@ withOneTrust(analytics).load({ writeKey: ' }) - We build three versions of the library: -1. `cjs` (CommonJS modules) - for library users -2. `esm` (es6 modules) - for library users +1. `cjs` (CommonJS modules) - for npm library users +2. `esm` (es6 modules) - for npm library users 3. `umd` (bundle) - for snippet users (typically) ### Browser Support -- `cjs/esm` - ONLY support modern JS syntax. We expect our typical `npm install` users to employ something like babel if they need legacy browser support. +- `cjs/esm` - Support modern JS syntax (ES2020). These are our npm library users, so we expect them to transpile this module themselves using something like babel/webpack if they need extra legacy browser support. - `umd` - Support back to IE11, but **do not** polyfill . See our docs on [supported browsers](https://segment.com/docs/connections/sources/catalog/libraries/website/javascript/supported-browsers). diff --git a/turbo.json b/turbo.json index aa1a3925b..f4c96f090 100644 --- a/turbo.json +++ b/turbo.json @@ -5,9 +5,11 @@ "dependsOn": ["^build"], "inputs": [ "**/tsconfig*.json", + "**/babel.config*", + "**/webpack.config*", "**/*.ts", "**/*.tsx", - ":!**/__tests__/**" + "!**/__tests__/**" ], "outputs": ["**/dist/**", ".next/**"] }, diff --git a/yarn.lock b/yarn.lock index 091772885..11d7a833e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2507,6 +2507,7 @@ __metadata: "@types/circular-dependency-plugin": ^5 babel-loader: ^8.0.0 circular-dependency-plugin: ^5.2.2 + ecma-version-validator-webpack-plugin: ^1.2.1 terser-webpack-plugin: ^5.1.4 webpack: ^5.76.0 webpack-cli: ^4.8.0 @@ -6811,7 +6812,7 @@ __metadata: prettier: ^2.6.2 ts-jest: ^28.0.4 ts-node: ^10.8.0 - turbo: ^1.3.1 + turbo: ^1.10.14 typescript: ^4.7.0 webpack: ^5.76.0 webpack-dev-server: ^4.15.1 @@ -9707,6 +9708,17 @@ __metadata: languageName: node linkType: hard +"ecma-version-validator-webpack-plugin@npm:^1.2.1": + version: 1.2.1 + resolution: "ecma-version-validator-webpack-plugin@npm:1.2.1" + dependencies: + acorn: ^8.7.0 + peerDependencies: + webpack: ^4.40.0 || ^5.0.0 + checksum: 9a0f6d9beb600f1af054f65a52790c3784d5d4c19cb10b9ae7446682613349ade952b355cca0e60b45616e66ce9b1914d183a909ce136bb05b47f364dd6bfabf + languageName: node + linkType: hard + "edge-paths@npm:^3.0.5": version: 3.0.5 resolution: "edge-paths@npm:3.0.5" @@ -19865,154 +19877,74 @@ __metadata: languageName: node linkType: hard -"turbo-android-arm64@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-android-arm64@npm:1.3.1" - conditions: os=android & cpu=arm64 - languageName: node - linkType: hard - -"turbo-darwin-64@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-darwin-64@npm:1.3.1" +"turbo-darwin-64@npm:1.10.14": + version: 1.10.14 + resolution: "turbo-darwin-64@npm:1.10.14" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"turbo-darwin-arm64@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-darwin-arm64@npm:1.3.1" +"turbo-darwin-arm64@npm:1.10.14": + version: 1.10.14 + resolution: "turbo-darwin-arm64@npm:1.10.14" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"turbo-freebsd-64@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-freebsd-64@npm:1.3.1" - conditions: os=freebsd & cpu=x64 - languageName: node - linkType: hard - -"turbo-freebsd-arm64@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-freebsd-arm64@npm:1.3.1" - conditions: os=freebsd & cpu=arm64 - languageName: node - linkType: hard - -"turbo-linux-32@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-linux-32@npm:1.3.1" - conditions: os=linux & cpu=ia32 - languageName: node - linkType: hard - -"turbo-linux-64@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-linux-64@npm:1.3.1" +"turbo-linux-64@npm:1.10.14": + version: 1.10.14 + resolution: "turbo-linux-64@npm:1.10.14" conditions: os=linux & cpu=x64 languageName: node linkType: hard -"turbo-linux-arm64@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-linux-arm64@npm:1.3.1" +"turbo-linux-arm64@npm:1.10.14": + version: 1.10.14 + resolution: "turbo-linux-arm64@npm:1.10.14" conditions: os=linux & cpu=arm64 languageName: node linkType: hard -"turbo-linux-arm@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-linux-arm@npm:1.3.1" - conditions: os=linux & cpu=arm - languageName: node - linkType: hard - -"turbo-linux-mips64le@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-linux-mips64le@npm:1.3.1" - conditions: os=linux & cpu=mips64el - languageName: node - linkType: hard - -"turbo-linux-ppc64le@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-linux-ppc64le@npm:1.3.1" - conditions: os=linux & cpu=ppc64 - languageName: node - linkType: hard - -"turbo-windows-32@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-windows-32@npm:1.3.1" - conditions: os=win32 & cpu=ia32 - languageName: node - linkType: hard - -"turbo-windows-64@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-windows-64@npm:1.3.1" +"turbo-windows-64@npm:1.10.14": + version: 1.10.14 + resolution: "turbo-windows-64@npm:1.10.14" conditions: os=win32 & cpu=x64 languageName: node linkType: hard -"turbo-windows-arm64@npm:1.3.1": - version: 1.3.1 - resolution: "turbo-windows-arm64@npm:1.3.1" +"turbo-windows-arm64@npm:1.10.14": + version: 1.10.14 + resolution: "turbo-windows-arm64@npm:1.10.14" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"turbo@npm:^1.3.1": - version: 1.3.1 - resolution: "turbo@npm:1.3.1" - dependencies: - turbo-android-arm64: 1.3.1 - turbo-darwin-64: 1.3.1 - turbo-darwin-arm64: 1.3.1 - turbo-freebsd-64: 1.3.1 - turbo-freebsd-arm64: 1.3.1 - turbo-linux-32: 1.3.1 - turbo-linux-64: 1.3.1 - turbo-linux-arm: 1.3.1 - turbo-linux-arm64: 1.3.1 - turbo-linux-mips64le: 1.3.1 - turbo-linux-ppc64le: 1.3.1 - turbo-windows-32: 1.3.1 - turbo-windows-64: 1.3.1 - turbo-windows-arm64: 1.3.1 +"turbo@npm:^1.10.14": + version: 1.10.14 + resolution: "turbo@npm:1.10.14" + dependencies: + turbo-darwin-64: 1.10.14 + turbo-darwin-arm64: 1.10.14 + turbo-linux-64: 1.10.14 + turbo-linux-arm64: 1.10.14 + turbo-windows-64: 1.10.14 + turbo-windows-arm64: 1.10.14 dependenciesMeta: - turbo-android-arm64: - optional: true turbo-darwin-64: optional: true turbo-darwin-arm64: optional: true - turbo-freebsd-64: - optional: true - turbo-freebsd-arm64: - optional: true - turbo-linux-32: - optional: true turbo-linux-64: optional: true - turbo-linux-arm: - optional: true turbo-linux-arm64: optional: true - turbo-linux-mips64le: - optional: true - turbo-linux-ppc64le: - optional: true - turbo-windows-32: - optional: true turbo-windows-64: optional: true turbo-windows-arm64: optional: true bin: turbo: bin/turbo - checksum: fced49081f2c64aaf93a2499edb057bb05d30bd2074b9652610f939c9037869501fcc50e7ad05a48cec4a8b9d344cc1c4ea505edd45fe2f9639fb138fa55182b + checksum: 219d245bb5cc32a9f76b136b81e86e179228d93a44cab4df3e3d487a55dd2688b5b85f4d585b66568ac53166145352399dd2d7ed0cd47f1aae63d08beb814ebb languageName: node linkType: hard