-
Notifications
You must be signed in to change notification settings - Fork 143
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 Import doesn't work for me #206
Comments
@samw1989 hello, thank you for your report. Which runtime/platform are you working on? |
Node.js (v15). |
Sorry for delayed response. Yes, running modular system using "type": "module". I tried switching to CommonJS and require() works just fine. Only the ES6 import that is causing me trouble. |
@samw1989 I will try to rewrite to use es6 module syntax instead of commonjs. |
- Related issue: #206 - Problem not resolved: JSDOM --> canvas - Error: Could not resolve "canvas" - Warning: "./xhr-sync-worker.js" should be marked as external for use with "require.resolve"
https://github.com/SettingDust/article-parser Something I did for es6 xd. But not for current version. |
@SettingDust last month, I've created branch es6-module-format, and could not pass the test. The problem occurred with jsdom module. Do you have any suggestion? |
I've not runned into error
|
@SettingDust I see that your fork is quite far from my current version and you had added a lot of modifications, so they could not be merged easily. |
I mean your branch not run into error on my end |
@SettingDust at my local environment, it works as well too :) |
Just |
@SettingDust if so, rollup may help. Let's me try with Rollup to see if it works for us. |
I'm trying to use rollup for building now |
It's seems that we won't use the |
Thank you for your notice. I'm not sure if
|
|
@SettingDust I think |
Yes, it's that. So, for user who want to parse canvas as well. They should install it in their project I think |
@SettingDust It seems we have to wait for a while, until ES6 Module becomes more regular. More dependencies, more complicate to migrate. I've done with several public repos here, but sometimes these changes also cause unnecessary troubles! |
In fact, the main branch depends on |
It's ok now. #212 |
@SettingDust cool! I will merge, but keep it as rc version for right now. |
Run with npx needn't to install global in local and ci |
@SettingDust I'm testing at local environment. ES6 version works as well, however commonjs version doesn't work yet! ES6 evaluation: CommonJS version: |
Caused by esbuild not support dynamic import from https://github.com/ndaidong/article-parser/blob/main/src/utils/chooseBestUrl.js#L18 |
@SettingDust thank you, if so, I think we should keep it there, the issue will be fixed by itself 😄 |
Maybe we can disable the string comparison algorithm option temporary? Publish a version like 6.0.0-alpha |
@SettingDust string comparison is needed to predict the best URL of article (with it we can normalize the images path too). I consider the trade-off to be not worth it. |
Needn't remove entire module. Just disable the option to change algorithm. Use the default |
@SettingDust I've merge you pr #217 , let's check if it works for us in several more tests. |
Haven't repair the cjs dist issue |
@SettingDust yes, while using cjs version, I face problem with I found a workaround by copying a part of this lib to dist folder. |
@SettingDust I just released v6.0.0-rc1, let's give it a try. When we feel it's reliable enough, it will be merged into main branch. |
It's not caused by the dynamic import, MB. I'm looking into the esbuild |
Weird. It's can build without any changes. Maybe it is fixed by itself. It's seems that a "Quantum" lul. |
BTW, yarn not support version like
|
@SettingDust thank you for pointing out, I will merge your latest pr now. |
@SettingDust I don't know why but without my workaround, the issue is still happening Could you try there step: npm run reset # to clean everything
npm i
# temporarily remove `"type": "module"` within package.json, then
npm run eval:cjs https://www.detroitnews.com/story/news/local/detroit-city/2022/02/13/ambassador-bridge-protesters-arrests-blockade-border/6775095001/ |
He havent published his changes with a tag. We need use the github source for package. |
@SettingDust ok, I'm considering to change string comparison tool. The problem and code base of |
@SettingDust v6.0.0rc2 with your fix has been released, I see it works well now. |
my bad |
I published the version |
@Rabbitzzc thank you so much! I'm worrying you've forgot it. |
@SettingDust v6.0.0rc4 has been released. If nothing wrong, we can merge to main branch next week. |
- Related issue: extractus#206 - Problem not resolved: JSDOM --> canvas - Error: Could not resolve "canvas" - Warning: "./xhr-sync-worker.js" should be marked as external for use with "require.resolve"
Hello, very new to Javascript, so apologies if I'm just misunderstanding and this isn't a bug.
Per the documentation, I ran:
import { extract } from 'article-parser'
This doesn't work for me. It leads to:
SyntaxError: Named export 'extract' not found. The requested module 'article-parser' is a CommonJS module, which may not support all module.exports as named exports.
Running import main from 'article-parser', and then calling main.extract() does work.
The text was updated successfully, but these errors were encountered: