Skip to content
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

react-hotkeys-hook js distributions don't support IE. #212

Closed
cdavis1324 opened this issue Dec 8, 2019 · 9 comments
Closed

react-hotkeys-hook js distributions don't support IE. #212

cdavis1324 opened this issue Dec 8, 2019 · 9 comments

Comments

@cdavis1324
Copy link

Hello!

First of all, thanks for creating this useful package.

Unfortunately, default parameters aren't supported by any version of IE, so any project that is consuming this project won't be able to support IE. While I dream of a world where web devs will no longer have to support IE, this is sadly not going to be a reality for years to come.

The problem is that the current build for react-hotkeys-hook is targeting es2018 which outputs a javascript dist that contains the usage of default parameters:

import hotkeys from 'hotkeys-js';
import { useCallback, useEffect } from "react";
export function useHotkeys(keys, callback, deps = []) {
    const memoisedCallback = useCallback(callback, deps);
    useEffect(() => {
        hotkeys(keys, memoisedCallback);
        return () => hotkeys.unbind(keys, memoisedCallback);
    }, [memoisedCallback]);
}

Fortunately, the fix here would be to simply change the target parameter within the tsconfig.json to target es2015 instead. This would ensure that the distributed js would be supported by more antiquated browsers like IE.

@JohannesKlauss
Copy link
Owner

@Wallysburg Thx for creating the issue. I will dig into that. At first glance it seems that pika pack is ignoring the target of the tsconfig, but I need to look into that.

@ypresto
Copy link

ypresto commented Feb 10, 2020

There is no config to output es2015 or es5 with @pika/plugin-ts-standard-pkg and @pika/plugin-build-web. @pika/plugin-bundle-web is the only way to do that but all node_modules will be bundled to a single file.

@giuvincenzi
Copy link

giuvincenzi commented Mar 17, 2020

Workaround - With webpack and babel this could be the solution:

{
  test: /\.js$/,
  exclude: /node_modules(?!(\/react-hotkeys-hook))/,
}

@reidphilpot
Copy link

👍 upvote for fixing this transpiling issue, thanks

@JohannesKlauss
Copy link
Owner

@ypresto Yeah you are right. There is unfortunately not much I can do about. I'd have to replace the whole building and publishing system.
Will think about that.

@JohannesKlauss
Copy link
Owner

@Wallysburg @reidphilpot For the time being I removed the usage of default parameters to fix this issue. Please check if 2.1.2 works for you in IE and let me know if there are any issues.

@joshwreford
Copy link

I'm using v2.1.3 and I'm still getting webpack errors thrown in IE11. Has anyone else had better luck?

@JohannesKlauss
Copy link
Owner

@joshwreford can you pinpoint what is causing the error?

@JohannesKlauss
Copy link
Owner

@joshwreford Can you check out v2.3.0 and try it in IE11?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants