es-module-shims 2.0.7 → 2.0.8

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/README.md CHANGED
@@ -28,7 +28,7 @@ Because we are still using the native module loader the edge cases work out comp
28
28
  Include ES Module Shims with a `async` attribute on the script, then include an import map and module scripts normally:
29
29
 
30
30
  ```html
31
- <script async src="https://ga.jspm.io/npm:es-module-shims@2.0.7/dist/es-module-shims.js"></script>
31
+ <script async src="https://ga.jspm.io/npm:es-module-shims@2.0.8/dist/es-module-shims.js"></script>
32
32
 
33
33
  <!-- https://generator.jspm.io/#U2NhYGBkDM0rySzJSU1hKEpNTC5xMLTQM9Az0C1K1jMAAKFS5w0gAA -->
34
34
  <script type="importmap">
@@ -553,7 +553,7 @@ Once enabled, the separate `es-module-shims-typescript.js` extension must be ava
553
553
  Example:
554
554
 
555
555
  ```html
556
- <script async src="https://ga.jspm.io/npm:es-module-shims@2.0.7/dist/es-module-shims.js"></script>
556
+ <script async src="https://ga.jspm.io/npm:es-module-shims@2.0.8/dist/es-module-shims.js"></script>
557
557
  <script type="esms-options">
558
558
  {
559
559
  "polyfillEnable": "all"
@@ -512,7 +512,10 @@ function transformSync(source, options) {
512
512
  const amaroTransformSync = module.exports.transformSync;
513
513
  export function transform(source, url) {
514
514
  try {
515
- return amaroTransformSync(source, { filename: url, transform: { mode: 'strip-only', noEmptyExport: true } }).code;
515
+ const transformed = amaroTransformSync(source, { filename: url, transform: { mode: 'strip-only', noEmptyExport: true } }).code;
516
+ // Importantly, return undefined when there is no work to do
517
+ if (transformed !== source)
518
+ return transformed;
516
519
  } catch (e) {
517
520
  // This is needed pending figuring out why filename option above isn't working
518
521
  throw new SyntaxError(e.message.replace(',-', url + ' - '));
@@ -1,4 +1,4 @@
1
- /* ES Module Shims 2.0.7 */
1
+ /* ES Module Shims 2.0.8 */
2
2
  (function () {
3
3
 
4
4
  const hasDocument = typeof document !== 'undefined';
@@ -945,7 +945,7 @@
945
945
  const source = await res.text();
946
946
  if (!esmsTsTransform) await initTs();
947
947
  const transformed = esmsTsTransform(source, url);
948
- return { r, s: transformed || source, t: transformed ? 'ts' : 'js' };
948
+ return { r, s: transformed === undefined ? source : transformed, t: transformed !== undefined ? 'ts' : 'js' };
949
949
  } else
950
950
  throw Error(
951
951
  `Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
@@ -1165,15 +1165,16 @@
1165
1165
  if (script.lang === 'ts' && !script.src) {
1166
1166
  const source = script.innerHTML;
1167
1167
  return initTs()
1168
- .then(() =>
1169
- topLevelLoad(
1168
+ .then(() => {
1169
+ const transformed = esmsTsTransform(source, baseUrl);
1170
+ return topLevelLoad(
1170
1171
  baseUrl,
1171
1172
  getFetchOpts(script),
1172
- esmsTsTransform(source, baseUrl) || source,
1173
- undefined,
1173
+ transformed === undefined ? source : transformed,
1174
+ transformed === undefined,
1174
1175
  undefined
1175
- )
1176
- )
1176
+ );
1177
+ })
1177
1178
  .catch(throwError);
1178
1179
  }
1179
1180
  console.info(`es-module-shims: checking script ${script.src || '<inline>'}`);
@@ -1,4 +1,4 @@
1
- /* ES Module Shims 2.0.7 */
1
+ /* ES Module Shims 2.0.8 */
2
2
  (function () {
3
3
 
4
4
  const hasDocument = typeof document !== 'undefined';
@@ -930,7 +930,7 @@
930
930
  const source = await res.text();
931
931
  if (!esmsTsTransform) await initTs();
932
932
  const transformed = esmsTsTransform(source, url);
933
- return { r, s: transformed || source, t: transformed ? 'ts' : 'js' };
933
+ return { r, s: transformed === undefined ? source : transformed, t: transformed !== undefined ? 'ts' : 'js' };
934
934
  } else
935
935
  throw Error(
936
936
  `Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
@@ -1145,15 +1145,16 @@
1145
1145
  if (script.lang === 'ts' && !script.src) {
1146
1146
  const source = script.innerHTML;
1147
1147
  return initTs()
1148
- .then(() =>
1149
- topLevelLoad(
1148
+ .then(() => {
1149
+ const transformed = esmsTsTransform(source, baseUrl);
1150
+ return topLevelLoad(
1150
1151
  baseUrl,
1151
1152
  getFetchOpts(script),
1152
- esmsTsTransform(source, baseUrl) || source,
1153
- undefined,
1153
+ transformed === undefined ? source : transformed,
1154
+ transformed === undefined,
1154
1155
  undefined
1155
- )
1156
- )
1156
+ );
1157
+ })
1157
1158
  .catch(throwError);
1158
1159
  }
1159
1160
  // does this load block readystate complete
@@ -1,4 +1,4 @@
1
- /* ES Module Shims Wasm 2.0.7 */
1
+ /* ES Module Shims Wasm 2.0.8 */
2
2
  (function () {
3
3
 
4
4
  const hasDocument = typeof document !== 'undefined';
@@ -930,7 +930,7 @@
930
930
  const source = await res.text();
931
931
  if (!esmsTsTransform) await initTs();
932
932
  const transformed = esmsTsTransform(source, url);
933
- return { r, s: transformed || source, t: transformed ? 'ts' : 'js' };
933
+ return { r, s: transformed === undefined ? source : transformed, t: transformed !== undefined ? 'ts' : 'js' };
934
934
  } else
935
935
  throw Error(
936
936
  `Unsupported Content-Type "${contentType}" loading ${url}${fromParent(parent)}. Modules must be served with a valid MIME type like application/javascript.`
@@ -1145,15 +1145,16 @@
1145
1145
  if (script.lang === 'ts' && !script.src) {
1146
1146
  const source = script.innerHTML;
1147
1147
  return initTs()
1148
- .then(() =>
1149
- topLevelLoad(
1148
+ .then(() => {
1149
+ const transformed = esmsTsTransform(source, baseUrl);
1150
+ return topLevelLoad(
1150
1151
  baseUrl,
1151
1152
  getFetchOpts(script),
1152
- esmsTsTransform(source, baseUrl) || source,
1153
- undefined,
1153
+ transformed === undefined ? source : transformed,
1154
+ transformed === undefined,
1154
1155
  undefined
1155
- )
1156
- )
1156
+ );
1157
+ })
1157
1158
  .catch(throwError);
1158
1159
  }
1159
1160
  // does this load block readystate complete
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "es-module-shims",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "Shims for the latest ES module features",
5
5
  "main": "dist/es-module-shims.js",
6
6
  "exports": {