skypackjs / skypack-cdn

An issue tracker for the CDN
107 stars 5 forks source link

ESM module error due to no default exported. #269

Open benzsuankularb opened 2 years ago

benzsuankularb commented 2 years ago
import { OrbitControls } from "https://cdn.skypack.dev/three/examples/jsm/controls/OrbitControls.js"

Caused below error in the browser...

Uncaught SyntaxError: The requested module '/-/three@v0.137.5-HJEdoVYPhjkiJWkt6XIa/dist=es2019,mode=raw/examples/jsm/controls/OrbitControls.js' does not provide an export named 'default'

Due to Skypack import both * and default of the target ESM which didn't exist.

/*
 * Skypack CDN - three@0.137.5
 *
 * Learn more:
 *   📙 Package Documentation: https://www.skypack.dev/view/three
 *   📘 Skypack Documentation: https://www.skypack.dev/docs
 *
 * Pinned URL: (Optimized for Production)
 *   ▶️ Normal: https://cdn.skypack.dev/pin/three@v0.137.5-HJEdoVYPhjkiJWkt6XIa/mode=raw/examples/jsm/controls/OrbitControls.js
 *   ⏩ Minified: https://cdn.skypack.dev/pin/three@v0.137.5-HJEdoVYPhjkiJWkt6XIa/mode=raw,min/examples/jsm/controls/OrbitControls.js
 *
 */

// Browser-Optimized Imports (Don't directly import the URLs below in your application!)
export * from '/-/three@v0.137.5-HJEdoVYPhjkiJWkt6XIa/dist=es2019,mode=raw/examples/jsm/controls/OrbitControls.js';
export {default} from '/-/three@v0.137.5-HJEdoVYPhjkiJWkt6XIa/dist=es2019,mode=raw/examples/jsm/controls/OrbitControls.js'; 
             ^^^^^^ This cause the error.
benzsuankularb commented 2 years ago

Do we have any query option to skip the default import or non-default import for example?

import { OrbitControls } from "https://cdn.skypack.dev/three/examples/jsm/controls/OrbitControls.js?skip-default"