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

The default export of @actions/artifact@2.0.0 is incorrect #1606

Closed
AnnAngela opened this issue Dec 13, 2023 · 5 comments
Closed

The default export of @actions/artifact@2.0.0 is incorrect #1606

AnnAngela opened this issue Dec 13, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@AnnAngela
Copy link

AnnAngela commented Dec 13, 2023

Describe the bug

After upgrading to @actions/artifact@2.0.0, I found out that the default export is incorrect, see the reproduce code below:

To Reproduce

The reproduce code: https://github.com/AnnAngela/AnnAngela/blob/58d95c9ca456e2aa18943eb7e4f25d7a40406173/test.mjs

The output: https://github.com/AnnAngela/AnnAngela/actions/runs/7190162702/job/19582850361#step:5:1

Expected behavior
The below code should work fine:

import artifact from "@actions/artifact";

await artifact.uploadArtifact("somefile", [somePath], rootPath); // => `TypeError: artifact.uploadArtifact is not a function` in @actions/artifact@2.0.0
@AnnAngela AnnAngela added the bug Something isn't working label Dec 13, 2023
@zyd14
Copy link

zyd14 commented Dec 13, 2023

I'm seeing issues with this too, preventing our builds from completing

@robherley
Copy link
Contributor

👋 I apologize for the confusion!

I think this might be something wrong with the configuration of how our TypeScript config is transpiling the modules. The default export works when using ts. I'll take a look to see how this can be resolved.

In the meantime, to avoid any possible breaking import changes, you can import and instanitate the default client (which is what the default export is):

import { DefaultArtifactClient } from "@actions/artifact";
const artifactClient = new DefaultArtifactClient();

And you should be good to go 👍

@robherley
Copy link
Contributor

I've updated the readme:

After talking with the team, we're not looking to turn this into a module yet. So we'll just avoid using default exports for now to avoid confusion between all the different module kinds 👍

@AnnAngela
Copy link
Author

AnnAngela commented Dec 15, 2023

@robherley Huge thanks for the clarification in the documentation (11a2dd3), just a little suggestion: would you like to beautify the code in these two line:

import {DefaultArtifactClient} from '@actions/artifact'

const {DefaultArtifactClient} = require('@actions/artifact')

@robherley
Copy link
Contributor

Our prettier config does not use bracket spacing unfortunately 😅

Since everything is clarified now, I'll close out the issue. Thanks for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants