@parcel/runtime-js
Advanced tools
Comparing version 2.0.0-canary.1761 to 2.0.0-canary.1763
@@ -189,3 +189,6 @@ "use strict"; | ||
// URL dependency or not, fall back to including a runtime that exports the url | ||
assets.push(getURLRuntime(dependency, bundle, mainBundle, options)); | ||
let mainAsset = mainBundle.getEntryAssets().find(e => e.id === bundleGroup.entryAssetId); | ||
if (dependency.specifierType === 'url' || mainBundle.type !== 'js' || (mainAsset === null || mainAsset === void 0 ? void 0 : mainAsset.meta.jsRuntime) === 'url') { | ||
assets.push(getURLRuntime(dependency, bundle, mainBundle, options)); | ||
} | ||
} | ||
@@ -196,3 +199,3 @@ | ||
// Therefore, we need to also ensure that the siblings are loaded when the child loads. | ||
if (options.shouldBuildLazily && bundle.env.outputFormat === 'global') { | ||
if (options.shouldBuildLazily && !bundle.env.shouldScopeHoist) { | ||
let referenced = bundleGraph.getReferencedBundles(bundle); | ||
@@ -328,3 +331,3 @@ for (let referencedBundle of referenced) { | ||
// user can try again (e.g. after fixing a build error). | ||
if (options.mode === 'development' && bundle.env.outputFormat === 'global') { | ||
if (options.mode === 'development' && !bundle.env.shouldScopeHoist) { | ||
code += '.catch(err => {delete module.bundle.cache[module.id]; throw err;})'; | ||
@@ -451,2 +454,4 @@ } | ||
} | ||
} else if (from.env.isServer() && to.env.isBrowser()) { | ||
code = `module.exports = ${JSON.stringify((0, _utils().urlJoin)(to.target.publicUrl, to.name))};`; | ||
} else { | ||
@@ -453,0 +458,0 @@ code = `module.exports = ${getAbsoluteUrlExpr(relativePathExpr, from)};`; |
{ | ||
"name": "@parcel/runtime-js", | ||
"version": "2.0.0-canary.1761+d19b1f6bd", | ||
"version": "2.0.0-canary.1763+3a064724a", | ||
"license": "MIT", | ||
@@ -20,11 +20,11 @@ "publishConfig": { | ||
"node": ">= 16.0.0", | ||
"parcel": "^2.0.0-canary.1759+d19b1f6bd" | ||
"parcel": "^2.0.0-canary.1761+3a064724a" | ||
}, | ||
"dependencies": { | ||
"@parcel/diagnostic": "2.0.0-canary.1761+d19b1f6bd", | ||
"@parcel/plugin": "2.0.0-canary.1761+d19b1f6bd", | ||
"@parcel/utils": "2.0.0-canary.1761+d19b1f6bd", | ||
"@parcel/diagnostic": "2.0.0-canary.1763+3a064724a", | ||
"@parcel/plugin": "2.0.0-canary.1763+3a064724a", | ||
"@parcel/utils": "2.0.0-canary.1763+3a064724a", | ||
"nullthrows": "^1.1.1" | ||
}, | ||
"gitHead": "d19b1f6bdb05eb5a3085f44daae15c0fe2709ab9" | ||
"gitHead": "3a064724a9589142ace59eb8920630f3ecdb1925" | ||
} |
@@ -14,3 +14,3 @@ // @flow strict-local | ||
import {Runtime} from '@parcel/plugin'; | ||
import {relativeBundlePath} from '@parcel/utils'; | ||
import {relativeBundlePath, urlJoin} from '@parcel/utils'; | ||
import path from 'path'; | ||
@@ -192,3 +192,12 @@ import nullthrows from 'nullthrows'; | ||
// URL dependency or not, fall back to including a runtime that exports the url | ||
assets.push(getURLRuntime(dependency, bundle, mainBundle, options)); | ||
let mainAsset = mainBundle | ||
.getEntryAssets() | ||
.find(e => e.id === bundleGroup.entryAssetId); | ||
if ( | ||
dependency.specifierType === 'url' || | ||
mainBundle.type !== 'js' || | ||
mainAsset?.meta.jsRuntime === 'url' | ||
) { | ||
assets.push(getURLRuntime(dependency, bundle, mainBundle, options)); | ||
} | ||
} | ||
@@ -199,3 +208,3 @@ | ||
// Therefore, we need to also ensure that the siblings are loaded when the child loads. | ||
if (options.shouldBuildLazily && bundle.env.outputFormat === 'global') { | ||
if (options.shouldBuildLazily && !bundle.env.shouldScopeHoist) { | ||
let referenced = bundleGraph.getReferencedBundles(bundle); | ||
@@ -376,6 +385,3 @@ for (let referencedBundle of referenced) { | ||
// user can try again (e.g. after fixing a build error). | ||
if ( | ||
options.mode === 'development' && | ||
bundle.env.outputFormat === 'global' | ||
) { | ||
if (options.mode === 'development' && !bundle.env.shouldScopeHoist) { | ||
code += | ||
@@ -576,2 +582,6 @@ '.catch(err => {delete module.bundle.cache[module.id]; throw err;})'; | ||
} | ||
} else if (from.env.isServer() && to.env.isBrowser()) { | ||
code = `module.exports = ${JSON.stringify( | ||
urlJoin(to.target.publicUrl, to.name), | ||
)};`; | ||
} else { | ||
@@ -578,0 +588,0 @@ code = `module.exports = ${getAbsoluteUrlExpr(relativePathExpr, from)};`; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
75350
1856