hapijs / hapijs/lab

Babel Preset transform is breaking on updating node version

Open
#1,066 0 comments 0 reactions 0 assignees View on GitHub
support
Dominant language
JavaScript
Stars
736
Forks
177
PR merge metrics
No merged PRs in 30d

Description

#### 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.