-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
classnames_1.default is not a function #1
Comments
I also tried changing my
|
Adding the following to the actual classnames source code does fix everything: Object.defineProperty(exports, "__esModule", { value: true });
exports.default = classNames; But I'm not at all sure that's the right approach, or I would submit a PR. |
I think I've identified the problem as the fact that my webpack setup transpiles with TypeScript first, followed by Babel. Since they have different ways of importing, that's the problem. I could theoretically have TS compile to an ES5 target, but then other things break, like livereload. I think the solution, at this point, is to just fix the classnames module to properly export its default module, for which I've submitted a PR. |
On my
classnames branch
, the dev server starts just fine withnpm start
; however, I get the following runtime error when I try to load the home page:Next, I tried changing the import statement in Home.js from:
to:
And now I get another runtime error, but it displays in-browser:
Now, I tried what @bowdenk7 and @DanielRosenwasser suggested by manually changing the classnames definition to the following:
I also tried
export default classNames
as well asdeclare function classNames(...classes: ClassValue[]): string;
But I get the exact same error at runtime in the browser, so I inspected the source code of classnames and found this gem:
Which made me realize that it actually does return a function, so I changed the import syntax back to:
No dice, so I added the
allowSyntheticDefaultImports
compiler flag in mytsconfig.json
and now I get:I cannot find a fix here! Is the issue with the classnames library? Because this all works perfectly in Babel compilation.
The text was updated successfully, but these errors were encountered: