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

asset.package is deprecated - fix #9

Merged
merged 3 commits into from
Sep 20, 2018

Conversation

elwin013
Copy link
Owner

@elwin013 elwin013 commented Sep 17, 2018

@apvarun please check and merge if it is ok. :-)

// edit: will fix #5

@apvarun
Copy link
Contributor

apvarun commented Sep 18, 2018

The getPackage() function is an asynchronous function and so you will need to use async/await to handle the function call. Calling it directly doesn't give the package.json file content.

Error in console: Please use await asset.getPackage() instead.

@elwin013 elwin013 force-pushed the asset-package-is-deprecated-message branch from 0345320 to 484ad91 Compare September 18, 2018 19:09
@elwin013
Copy link
Owner Author

@apvarun Thank you for checking it and informing me about my stupid mistake. :-) Could you review again?

I've pushed another change - now I'm just resolving promise (getPackage()), but also fixed code for parcel 1.8.x (getPackage() was introduced in 1.9.x)

@apvarun
Copy link
Contributor

apvarun commented Sep 19, 2018

Changes look good regarding resolving the promise. But since"bundler.mainAsset.package.pkgfile" is still supported, the warning is still present. I guess the parcel version >= 1.9 should be resolved first before other cases.

Copy link
Contributor

@apvarun apvarun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the order of evaluation, version 1.9 and above to be evaluated first before older versions.

@elwin013
Copy link
Owner Author

Well, TIL that hasOwnProperty doesn't work if method is defined in prototype (and getPackage seems to be defined like this). I've fixed condition - now everything should work ok (checked for 1.9.4, 1.8.0, 1.7.1). :-)

Copy link
Contributor

@apvarun apvarun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@apvarun apvarun merged commit 4421f18 into master Sep 20, 2018
@elwin013
Copy link
Owner Author

Hello @Tolgor! Thank you for you comment. Could you provide some example to replicate this error? On my side everything is working as mentioned above.

@elwin013 elwin013 deleted the asset-package-is-deprecated-message branch September 20, 2018 17:00
@Tolgor
Copy link

Tolgor commented Sep 21, 2018

os: Windows 10
node: v8.11.3
parcel-bundler: v1.9.7

My local fixes

Fix on getPackage() Promise await

// for parcel-bundler@>=1.9
pkgFile = await bundler.mainBundle.entryAsset.getPackage();

Fix on destination resolution (was broken on Windows)

const copy = (filepath, relative, filename) => {
    const dest = path.join(bundleDir, path.relative(staticDir, filepath));
    [...]
}

@elwin013
Copy link
Owner Author

@Tolgor created issue for that (#11). Can you check if problem still persist in 1.2.3 version?

@elwin013 elwin013 restored the asset-package-is-deprecated-message branch June 3, 2020 16:25
@elwin013 elwin013 deleted the asset-package-is-deprecated-message branch June 3, 2020 16:26
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

Successfully merging this pull request may close these issues.

asset.package is deprecated
3 participants