Skip to content

Commit 5318bc3

Browse files
shakyShaneShane Osbourne
and
Shane Osbourne
authored
Per-platform feature bundling (#447)
* drop dynamic import * PR review * updated package.json * typed 'magic' imports + fixed a bug with lookups * removed apple isolated * always pass 'platform' --------- Co-authored-by: Shane Osbourne <[email protected]>
1 parent 26c979a commit 5318bc3

File tree

10 files changed

+211
-177
lines changed

10 files changed

+211
-177
lines changed

package-lock.json

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"minimist": "^1.2.8",
6767
"puppeteer": "^19.9.1",
6868
"rollup": "^3.20.6",
69-
"rollup-plugin-dynamic-import-variables": "^1.1.0",
7069
"typedoc": "^0.24.4",
7170
"typescript": "^5.0.4"
7271
}

scripts/inject.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,28 @@ const builds = {
4343
async function initOther (injectScriptPath, platformName) {
4444
const supportsMozProxies = platformName === 'firefox'
4545
const identName = `inject${camelcase(platformName)}`
46-
const injectScript = await rollupScript(injectScriptPath, identName, supportsMozProxies)
46+
const injectScript = await rollupScript({
47+
scriptPath: injectScriptPath,
48+
name: identName,
49+
supportsMozProxies,
50+
platform: platformName
51+
})
4752
const outputScript = injectScript
4853
return outputScript
4954
}
5055

5156
/**
5257
* @param {string} entry
58+
* @param {string} platformName
5359
*/
54-
async function initChrome (entry) {
60+
async function initChrome (entry, platformName) {
5561
const replaceString = '/* global contentScopeFeatures */'
56-
const injectScript = await rollupScript(entry)
57-
const contentScope = await rollupScript(contentScopePath, contentScopeName)
62+
const injectScript = await rollupScript({ scriptPath: entry, platform: platformName })
63+
const contentScope = await rollupScript({
64+
scriptPath: contentScopePath,
65+
name: contentScopeName,
66+
platform: platformName
67+
})
5868
// Encode in URI format to prevent breakage (we could choose to just escape ` instead)
5969
// NB: .replace(/\r\n/g, "\n") is needed because in Windows rollup generates CRLF line endings
6070
const encodedString = encodeURI(contentScope.toString().replace(/\r\n/g, '\n'))
@@ -74,7 +84,7 @@ async function init () {
7484

7585
let output
7686
if (args.platform === 'chrome') {
77-
output = await initChrome(build.input)
87+
output = await initChrome(build.input, args.platform)
7888
} else {
7989
output = await initOther(build.input, args.platform)
8090
}

0 commit comments

Comments
 (0)