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

Babel Preset transform is breaking on updating node version #1066

Open
sathyalog opened this issue Sep 14, 2023 · 0 comments
Open

Babel Preset transform is breaking on updating node version #1066

sathyalog opened this issue Sep 14, 2023 · 0 comments
Labels
support Questions, discussions, and general support

Comments

@sathyalog
Copy link

sathyalog commented Sep 14, 2023

Support plan

  • is this issue currently blocking your project? (yes/no): Yes
  • is this issue affecting a production system? (yes/no): yes

Context

  • node version: 18.16.0
  • module version: 24.0.0
  • environment (e.g. node, browser, native): node(test cases are failing when we run yarn test coverage command)
  • used with (e.g. hapi application, another framework, standalone, ...): hapi library used
  • any other relevant information: Nodejs with hapi library. Webpack used to build the package.

How can we help?

Hi Team,

In our application earlier we were using node 16.20.0 with webpack 4 and hapi libraries used for multiple purpose and hapi lab(24.0.0) used for unit test cases. We have a babel config file(transform.js) like shown in the code snippet used in our package json script

let transformed = Babel.transform(content, {
        presets: [
            "@babel/preset-react",
            "@babel/typescript",
            [
                "@babel/preset-env",
                {
                    targets: {
                        node: 12,
                    },,
                },
            ],
        ],
        filename: filename,
        sourceMap: "inline",
        sourceFileName: filename,
        auxiliaryCommentBefore: "$lab:coverage:off$",
        auxiliaryCommentAfter: "$lab:coverage:on$",
        plugins: [
            "@babel/plugin-proposal-export-default-from",
            "@babel/plugin-proposal-class-properties",
            "@babel/plugin-proposal-private-property-in-object",
            "@babel/plugin-proposal-private-methods",
            "@babel/plugin-transform-runtime",
            "@babel/plugin-syntax-dynamic-import",
            [
                "module-resolver",
                {
                    alias: {
                        "@govuk-jsx": path.join(
                            path.dirname(
                                require.resolve(
                                    "@xgovformbuilder/govuk-react-jsx"
                                )
                            ),
                            "/components"
                        ),
                    },
                },
            ],
            [
                "babel-plugin-transform-import-ignore",
                {
                    patterns: [".css", ".scss", "wildcard/*/match.css"],
                },
            ],
        ],
        exclude: ["node_modules/**"],
        ignore: ["../node_modules", "node_modules"],
    });

package.json script:
"test-lab-cov": "lab -T test/.transform.js test/.setup.js ./**/.test. -S -v -t 87 -r console -o stdout -r lcov -o test-coverage/lab/lcov.info -r html -o test-coverage/lab/unit-test.html -r junit -o test-results/lab/unit-test.xml -I version -l",

### PROBLEM:
Now we have upgraded our application from node 16.20.0 to node 18.16.0 and upgraded webpack 4 to webpack 5. Now after this upgrade, when we run the script test-lab-cov. It throws the following errors like shown in screenshots. I tried upgrading minor versions of hapi lab libraries, babel core, babel eslint etc but still the error is not resolved.

Can anyone please let me know where its going wrong and how can we fix this to work hapi lab with node 18.16.0?

Pls advise if you have any suggestions.

Thanks
Screenshot 2023-09-14 at 09 12 18
Screenshot 2023-09-14 at 09 12 36

@sathyalog sathyalog added the support Questions, discussions, and general support label Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Questions, discussions, and general support
Projects
None yet
Development

No branches or pull requests

1 participant