jsvat icon indicating copy to clipboard operation
jsvat copied to clipboard

Internet explorer

Open bartdk-be opened this issue 5 years ago • 11 comments

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

bartdk-be avatar Oct 10 '19 09:10 bartdk-be

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

se-panfilov avatar Oct 10 '19 11:10 se-panfilov

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

bartdk-be avatar Oct 14 '19 09:10 bartdk-be

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.

treago avatar Oct 17 '19 07:10 treago

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

bartdk-be avatar Oct 17 '19 08:10 bartdk-be

@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

se-panfilov avatar Oct 21 '19 08:10 se-panfilov

@treago : Still having an issue when launching our site

image

image

bartdk-be avatar Oct 21 '19 13:10 bartdk-be

@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

se-panfilov avatar Oct 21 '19 14:10 se-panfilov

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)

bartdk-be avatar Oct 21 '19 19:10 bartdk-be

@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

se-panfilov avatar Oct 22 '19 11:10 se-panfilov

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

ghost avatar Oct 29 '19 07:10 ghost

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?

pesso82 avatar Apr 06 '20 16:04 pesso82