Skip to content

Commit 7a75f13

Browse files
authored
[FSSDK-11500] publish ua_parser as a separate bundle (#1045)
1 parent 02fad58 commit 7a75f13

File tree

4 files changed

+59
-29
lines changed

4 files changed

+59
-29
lines changed

lib/odp/ua_parser/ua_parser.browser.ts renamed to lib/odp/ua_parser/ua_parser.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
1716
import { UAParser } from 'ua-parser-js';
1817
import { UserAgentInfo } from './user_agent_info';
1918
import { UserAgentParser } from './user_agent_parser';
@@ -30,4 +29,3 @@ const userAgentParser: UserAgentParser = {
3029
export function getUserAgentParser(): UserAgentParser {
3130
return userAgentParser;
3231
}
33-

package-lock.json

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

package.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
},
3434
"./browser": {
3535
"types": "./dist/index.d.ts",
36-
"import": "./dist/index.browser.es.min.js",
37-
"require": "./dist/index.browser.min.js"
36+
"import": "./dist/index.browser.es.min.js",
37+
"require": "./dist/index.browser.min.js"
3838
},
3939
"./react_native": {
4040
"types": "./dist/index.d.ts",
@@ -46,6 +46,11 @@
4646
"types": "./dist/index.universal.d.ts",
4747
"import": "./dist/index.universal.es.min.js",
4848
"require": "./dist/index.universal.min.js"
49+
},
50+
"./ua_parser": {
51+
"types": "./dist/odp/ua_parser/ua_parser.d.ts",
52+
"import": "./dist/ua_parser.es.min.js",
53+
"require": "./dist/ua_parser.min.js"
4954
}
5055
},
5156
"scripts": {
@@ -89,7 +94,6 @@
8994
"decompress-response": "^7.0.0",
9095
"json-schema": "^0.4.0",
9196
"murmurhash": "^2.0.1",
92-
"ua-parser-js": "^1.0.38",
9397
"uuid": "^9.0.1"
9498
},
9599
"devDependencies": {
@@ -146,7 +150,8 @@
146150
"@react-native-async-storage/async-storage": "^1.2.0",
147151
"@react-native-community/netinfo": "^11.3.2",
148152
"fast-text-encoding": "^1.0.6",
149-
"react-native-get-random-values": "^1.11.0"
153+
"react-native-get-random-values": "^1.11.0",
154+
"ua-parser-js": "^1.0.38"
150155
},
151156
"peerDependenciesMeta": {
152157
"@react-native-async-storage/async-storage": {
@@ -160,6 +165,9 @@
160165
},
161166
"fast-text-encoding": {
162167
"optional": true
168+
},
169+
"ua-parser-js": {
170+
"optional": true
163171
}
164172
},
165173
"publishConfig": {

rollup.config.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,51 @@ const esmBundleFor = (platform, opt) => {
9393
}
9494
};
9595

96+
const cjsBundleForUAParser = (opt = {}) => {
97+
const { minify, ext } = {
98+
minify: true,
99+
ext: '.js',
100+
...opt,
101+
};
102+
103+
const min = minify ? '.min' : '';
104+
105+
return {
106+
plugins: [resolve(), commonjs(), typescript(typescriptPluginOptions)],
107+
external: ['https', 'http', 'url'].concat(Object.keys({ ...dependencies, ...peerDependencies } || {})),
108+
input: `lib/odp/ua_parser/ua_parser.ts`,
109+
output: {
110+
exports: 'named',
111+
format: 'cjs',
112+
file: `dist/ua_parser${min}${ext}`,
113+
plugins: minify ? [terser()] : undefined,
114+
sourcemap: true,
115+
},
116+
};
117+
};
118+
119+
const esmBundleForUAParser = (opt = {}) => {
120+
const { minify, ext } = {
121+
minify: true,
122+
ext: '.js',
123+
...opt,
124+
};
125+
126+
const min = minify ? '.min' : '';
127+
128+
return {
129+
...cjsBundleForUAParser(),
130+
output: [
131+
{
132+
format: 'es',
133+
file: `dist/ua_parser.es${min}${ext}`,
134+
plugins: minify ? [terser()] : undefined,
135+
sourcemap: true,
136+
},
137+
],
138+
};
139+
};
140+
96141
const umdBundle = {
97142
plugins: [
98143
resolve({ browser: true }),
@@ -147,6 +192,8 @@ const bundles = {
147192
'esm-react-native-min': esmBundleFor('react_native'),
148193
'esm-universal': esmBundleFor('universal'),
149194
'json-schema': jsonSchemaBundle,
195+
'cjs-ua-parser-min': cjsBundleForUAParser(),
196+
'esm-ua-parser-min': esmBundleForUAParser(),
150197
umd: umdBundle,
151198
};
152199

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy