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

Support ES Modules / Bump node version #100

Closed
mxkyb opened this issue Feb 24, 2022 · 0 comments
Closed

Support ES Modules / Bump node version #100

mxkyb opened this issue Feb 24, 2022 · 0 comments

Comments

@mxkyb
Copy link

mxkyb commented Feb 24, 2022

Hello,

first of all, great project!

There is a problem when using ES Modules for puppeteer scripts like this:

# action.yml
      - name: Audit
        uses: treosh/lighthouse-ci-action@v8
        with:
          urls: https://some.url
          configPath: ./lighthouserc.json
// lighthouserc.json
{
    "ci": {
        "collect": {
            "puppeteerScript": "index.cjs"
        }
    }
}
// index.cjs
module.exports = (...args) => {
    return import('./index.js').then((module) => {
        return module.default(...args);
    });
};
// index.js
import {something} from 'somewhere';

const doThings = async (browser) => {
    await something();
};

export default doThings;

This will result in

Error: Not supported
at module.exports ...

I think the problem comes from here, because es modules were still experimental in node 12.
https://github.com/treosh/lighthouse-ci-action/blob/main/action.yml#L35

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

No branches or pull requests

1 participant