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

Internet explorer #82

Open
bartdk-be opened this issue Oct 10, 2019 · 11 comments
Open

Internet explorer #82

bartdk-be opened this issue Oct 10, 2019 · 11 comments

Comments

@bartdk-be
Copy link

Any plans to make the latest version compatible with Internet Explorer 11 ?

@se-panfilov
Copy link
Owner

Well, in short - yes, but not very soon.

In other hand - if you will create a PR which provides that support - I'll add it to the lib

@bartdk-be
Copy link
Author

Any idea on where / how to fix this ?
We did a rollback to 1.2.4 in order to fix the issue, but now another exception is thrown

TypeError: Cannot read property 'countries' of undefined
at checkVAT (jsvat.js?87bc:95)

image

@treago
Copy link
Contributor

treago commented Oct 17, 2019

Well, in short - yes, but not very soon.

In other hand - if you will create a PR which provides that support - I'll add it to the lib

There is one #81 to solve the issue until your final decision, according to the thread #78.

@bartdk-be
Copy link
Author

@treago : Thanks ! Any chance I can validate this package ?
@se-panfilov

@se-panfilov
Copy link
Owner

se-panfilov commented Oct 21, 2019

@treago your PR now merged and available in version v2.1.4.
@bartdk-be I guess you can try to update and check if you problem is solved or not

@bartdk-be
Copy link
Author

@treago : Still having an issue when launching our site

image

image

@se-panfilov
Copy link
Owner

@bartdk-be okay, form what I see you use es6 version of the library. So I can assume that you use via import keyword, not require. @treago's fix targeted only commonjs modules (means nodejs env, and use of require keyword).

So, I don't know how do you assemble your bundle, but you can try to import jsvat explicitly, like const { checkVAT, belgium, austria } = require('jsvat/lib/commonjs'); (important part here is the path to 'jsvat/lib/commonjs' instead of just 'jsvat')

P.S. I'd like to know a bit more about the way you build the project and version of IE you do use

@bartdk-be
Copy link
Author

Even with the require, IE seems to fail.

  • Using yarn to build our project (webpack). Any particular information you need to facilitate investigation ?
  • Although we would like to depricate IE support, still forced due to high usage. Testing on version 11.418.18362 (windows 10)

@se-panfilov
Copy link
Owner

se-panfilov commented Oct 22, 2019

@bartdk-be

Well, I tried it myself and it basically works, the only thing - I implement it with react and react requires react-app-polyfill/ie11 to be launched in IE11.

if you will create basic react app with create-react-app or similar setup (I basically used webstorm's template).

Your index.js

// This must be the first line in src/index.js                       
import 'react-app-polyfill/ie11';                        //  <--- IMPORTANT for react

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

ReactDOM.render(<App />, document.getElementById('root'));

// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();

App.js

import React, {useState} from 'react';
import './App.css';

// this is works
// const {austria, belgium, checkVAT} = require('jsvat/lib/commonjs');

// this is also works
import {austria, belgium, checkVAT} from 'jsvat/lib/commonjs';


function App() {
    const [vat, setVat] = useState('BE0411905847');

    return (
        <div className="App">
            <header className="App-header">

                <input type="text" value={vat} onChange={({target}) => setVat(target ? target.value : '')}/>
                <br/>
                Result of jsvat:
                <div id="result">
                    <ul>
                        <li>Belgium: {checkVAT(vat, [belgium]).isValid.toString()}</li>
                        <li>Austria: {checkVAT(vat, [austria]).isValid.toString()}</li>
                    </ul>

                </div>

            </header>
        </div>
    );
}

export default App;

My package,json:

{
  "name": "jsvat-demo-react",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "jsvat": "^2.1.4",
    "react": "^16.10.2",
    "react-app-polyfill": "^1.0.4",
    "react-dom": "^16.10.2",
    "react-scripts": "3.2.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      "ie 11"                            // I guess it's also important
    ],
    "development": [
      "ie 11"
    ]
  }
}

So, basically it works for me in IE11 on windows

@ghost
Copy link

ghost commented Oct 29, 2019

We have the same issue. Building with Angular 7, which doesn't allow the use of 'require', only 'import'. But even importing from jsvat/lib/commonjs is giving the same error (Syntax error on calcFn). Using IE11 on Windows.

The demo website isn't loading in IE11 either (see attached screenshot).

jsvat-demo-website
ie11-version

@pesso82
Copy link

pesso82 commented Apr 6, 2020

Hi there, any news about the IE11 issue? This library is very useful, but missing IE support is a huge lack. Any ideas how to solve the issue?

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

No branches or pull requests

4 participants