Quick checklist
What package manager are you using?
yarn
What operating system are you using?
Linux
Describe the bug
Dev server fails with an Uncaught TypeError: require$$0 is not a function. This error occurs in a transformed file of a define-properties package.
It appears to me that this bug occurs due to incorrect transformation of that package require() call. In the package the following line:
var hasPropertyDescriptors = require('has-property-descriptors')();
is being transformed to
import * as hasPropertyDescriptors$1 from '/_snowpack/pkg/has-property-descriptors.v1.0.0.js';
function getDefaultExportFromNamespaceIfNotNamed (n) {
return n && Object.prototype.hasOwnProperty.call(n, 'default') && Object.keys(n).length === 1 ? n['default'] : n;
}
var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfNotNamed(hasPropertyDescriptors$1);
var hasPropertyDescriptors = require$$0();
in the original code the require() returns a function, in the transformed code however, the getDefaultExportFromNamespaceIfNotNamed()is returning the module with that function under a "default" property, leading to this error. I suspect this is because that module has more than one property and Object.keys(n).length === 1 condition returns false.
This error does occur only when using a development server.
Steps to reproduce
npx create-snowpack-app
- install define-properties (
npm i define-properties)
- import that package and use it
- start the dev server
- open the page in the browser
- it will fail with a
Uncaught TypeError: require$$0 is not a function error in the console
Link to minimal reproducible example (optional)
No response
Quick checklist
What package manager are you using?
yarn
What operating system are you using?
Linux
Describe the bug
Dev server fails with an
Uncaught TypeError: require$$0 is not a function. This error occurs in a transformed file of a define-properties package.It appears to me that this bug occurs due to incorrect transformation of that package
require()call. In the package the following line:is being transformed to
in the original code the
require()returns a function, in the transformed code however, thegetDefaultExportFromNamespaceIfNotNamed()is returning the module with that function under a "default" property, leading to this error. I suspect this is because that module has more than one property andObject.keys(n).length === 1condition returns false.This error does occur only when using a development server.
Steps to reproduce
npx create-snowpack-appnpm i define-properties)Uncaught TypeError: require$$0 is not a functionerror in the consoleLink to minimal reproducible example (optional)
No response