-
Notifications
You must be signed in to change notification settings - Fork 23
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
es6 imports #17
Comments
$ cat package.json
{
"private": true,
"type": "module",
"dependencies": {
"opencc-js": "^1.0.2"
}
} $ npm install $ cat index.js
import OpenCC from 'opencc-js';
const converter = OpenCC.Converter({ from: 'hk', to: 'cn' });
console.log(converter('漢語')); $ node index.js
汉语 |
Thanks for your reply @sgalal
Then in the browser I get |
That is strange. As a workaround you can use: import { Converter } from 'opencc-js';
const converter = Converter({ from: 'hk', to: 'cn' });
function App() {
return (<div className="App">{converter('漢語')}</div>);
}
export default App; I will release a new version as soon as I find a final solution. All the best for your project! |
Thanks @sgalal ! Actually I didn't think of trying that but I had forgotten that I had actually got a little further than that before. I can confirm that your code works (including in my app), however:
Gives the following:
I spent quite a while trying to figure out how to load the data files but that was over my level of JS unfortunately! |
And thanks! It's a PhD project @ CityU if you were wondering :-). |
@AntonOfTheWoods I am sorry for that. That is a bug in v1.0.2. I have just published v1.0.3 and it should work now. |
What a coincidence. I am applying for the MSc in Computer Science programme at CityU 😄 |
Well if you want to do a joint project with the Linguistics department on computer-assisted language learning then look no further!!!! :-D |
@sgalal , I can confirm it works perfectly now, thanks!!! It might not be very obvious for others wanting to use es6 imports with the |
Yes, I will leave it open until |
Sorry if this is obvious (JS is still somewhat opaque to me...), but how would one use this with es6 imports? I tried various versions of what is described here but none worked. Thanks!
The text was updated successfully, but these errors were encountered: