@jsenv/plugin-bundling 2.3.0 → 2.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/plugin-bundling",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -30,7 +30,7 @@
30
30
  "@jsenv/sourcemap": "1.1.0",
31
31
  "acorn-import-assertions": "1.9.0",
32
32
  "lightningcss": "1.21.5",
33
- "rollup": "3.26.2"
33
+ "rollup": "3.26.3"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "@jsenv/core": "*"
@@ -179,16 +179,35 @@ const rollupPluginJsenv = ({
179
179
  });
180
180
  return;
181
181
  }
182
+ let preserveSignature;
183
+ if (strictExports) {
184
+ preserveSignature = "strict";
185
+ } else {
186
+ // When referenced only once we can enable allow-extension
187
+ // otherwise stick to strict exports to ensure all importers
188
+ // receive the correct exports
189
+ let firstStrongRef = null;
190
+ let hasMoreThanOneStrongRefFromOther = false;
191
+ for (const referenceFromOther of jsModuleUrlInfo.referenceFromOthersSet) {
192
+ if (referenceFromOther.isWeak) {
193
+ continue;
194
+ }
195
+ if (firstStrongRef) {
196
+ hasMoreThanOneStrongRefFromOther = true;
197
+ break;
198
+ }
199
+ firstStrongRef = referenceFromOther;
200
+ }
201
+ preserveSignature = hasMoreThanOneStrongRefFromOther
202
+ ? "strict"
203
+ : "allow-extension";
204
+ }
182
205
  emitChunk({
183
206
  id,
184
207
  implicitlyLoadedAfterOneOf: previousNonEntryPointModuleId
185
208
  ? [previousNonEntryPointModuleId]
186
209
  : null,
187
- preserveSignature: strictExports
188
- ? "strict"
189
- : jsModuleUrlInfo.referenceFromOthersSet.size < 2
190
- ? "allow-extension"
191
- : "strict",
210
+ preserveSignature,
192
211
  });
193
212
  previousNonEntryPointModuleId = id;
194
213
  });