Skip to content

Commit

Permalink
[No Ticket] Prebid specific build (#384)
Browse files Browse the repository at this point in the history
* [No Ticket] Remove native bindings

* add prebid specific build

* fix path

* add comment

* fmt

* now with types!

* commonjs it is'

* remove old device
  • Loading branch information
mschuwalow committed May 3, 2024
1 parent 77c2a56 commit 5fb5395
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 11 deletions.
4 changes: 1 addition & 3 deletions package-lock.json

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

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
"require": "./dist/internal.cjs",
"import": "./dist/internal.mjs"
},
"./prebid": {
"types": "./dist/index.d.ts",
"require": "./dist/prebid.cjs"
},
"./package.json": "./package.json"
},
"files": [
Expand Down Expand Up @@ -114,8 +118,5 @@
"ts-node": "^10.9.1",
"typescript": "^5.1.6",
"url": "^0.11.1"
},
"optionalDependencies": {
"@rollup/rollup-linux-x64-gnu": "^4.9.6"
}
}
59 changes: 57 additions & 2 deletions rollup/dist.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ import ts from '@rollup/plugin-typescript'
import cleaner from 'rollup-plugin-cleaner'
import dts from 'rollup-plugin-dts'
import del from "rollup-plugin-delete";
import commonJs from '@rollup/plugin-commonjs'
import resolve from '@rollup/plugin-node-resolve'
import babel from '@rollup/plugin-babel'

const OUTPUT_DIR = './dist'
const DECLARATION_DIR = `${OUTPUT_DIR}/dts`

const prebid = {
input: "./src/index.ts",
tsOutput: `${OUTPUT_DIR}/prebid.ts.mjs`,
babelOutput: `${OUTPUT_DIR}/prebid.babel.mjs`,
output: `${OUTPUT_DIR}/prebid.cjs`
}

export default [
{
input: ['./src/index.ts', './src/internal.ts'],
Expand All @@ -28,7 +38,7 @@ export default [
],
plugins: [
cleaner({ targets: [OUTPUT_DIR] }),
ts({ compilerOptions: { declarationDir: DECLARATION_DIR } }),
ts({ compilerOptions: { declaration: true, declarationDir: DECLARATION_DIR } }),
strip()
],
external: [
Expand All @@ -43,5 +53,50 @@ export default [
},
output: [{ dir: OUTPUT_DIR, format: 'es' }],
plugins: [dts(), del({ targets: DECLARATION_DIR, hook: 'buildEnd' })],
}
},
//
// prebid build
//
{
input: prebid.input,
output: {
file: prebid.tsOutput,
format: 'esm',
sourcemap: false
},
plugins: [
commonJs({ sourceMap: false }),
resolve(),
ts(),
]
},
// transpile with babel
{
input: prebid.tsOutput,
output: {
file: prebid.babelOutput,
format: 'esm',
sourcemap: false
},
plugins: [
babel({ babelHelpers: 'bundled', configFile: './rollup/prebid.babel.config.json' }),
del({ targets: prebid.tsOutput, hook: 'buildEnd' })
],
external: [/core-js\/modules/] // will insert `import 'core-js/modules/...'`, we'll resolve this later
},
// minify and bundle
{
input: prebid.babelOutput,
output: {
file: prebid.output,
format: 'cjs',
sourcemap: false
},
plugins: [
commonJs({ sourceMap: false }),
resolve(),
strip(),
del({ targets: prebid.babelOutput, hook: 'buildEnd' })
]
},
]
13 changes: 13 additions & 0 deletions rollup/prebid.babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "usage",
"corejs": "3",
"debug": false
}
]
],
"targets": "> 0.25%, not IE 11, not op_mini all" // keep in sync with https://github.com/prebid/Prebid.js/blob/master/package.json#L20
}
2 changes: 1 addition & 1 deletion rollup/test-resources.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default [
}),
commonJs({ sourceMap: false }),
resolve(),
ts({compilerOptions: { declaration: false }}),
ts(),
]
},
// transpile with babel
Expand Down
1 change: 0 additions & 1 deletion test-config/wdio.browserstack.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ const allCapabilities = [
{ browserName: 'Safari', browserVersion: '14.0', 'bstack:options': { ...commonBStackCapabilities, deviceName: 'iPhone 12', osVersion: '14', realMobile: true } },
{ browserName: 'Safari', browserVersion: '13.0', 'bstack:options': { ...commonBStackCapabilities, deviceName: 'iPhone 11', osVersion: '13', realMobile: true } },
{ browserName: 'Safari', browserVersion: '12.0', 'bstack:options': { ...commonBStackCapabilities, deviceName: 'iPhone 8', osVersion: '12', realMobile: true } },
{ browserName: 'Safari', browserVersion: '11.0', 'bstack:options': { ...commonBStackCapabilities, deviceName: 'iPad Pro 9.7 2016', osVersion: '11', realMobile: true } },

{ browserName: 'Chrome', browserVersion: 'latest', 'bstack:options': { ...commonBStackCapabilities, deviceName: 'Samsung Galaxy S21', osVersion: '11.0', realMobile: true } },
{ browserName: 'Chrome', browserVersion: '67', 'bstack:options': { ...commonBStackCapabilities, deviceName: 'Samsung Galaxy S8', osVersion: '7.0', realMobile: true } }
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"esModuleInterop": true,
"resolveJsonModule": true,
"strict": true,
"declaration": true,
"declaration": false,
"sourceMap": false,
"moduleResolution": "NodeNext",
"module": "NodeNext",
Expand Down

0 comments on commit 5fb5395

Please sign in to comment.