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

fix:static class blocks are not enabled babel error #8267

Merged
merged 8 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
345 changes: 173 additions & 172 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-import-meta": "^7.10.4",
"@babel/plugin-transform-async-to-generator": "^7.22.5",
"@babel/plugin-transform-class-static-block": "^7.24.7",
"@babel/plugin-transform-exponentiation-operator": "^7.22.5",
"@babel/plugin-transform-for-of": "^7.22.15",
"@babel/plugin-transform-runtime": "7.23.3",
Expand Down Expand Up @@ -165,6 +166,7 @@
"@rollup/plugin-commonjs": "^11.0.2",
"@rollup/plugin-inject": "^4.0.2",
"@rollup/plugin-node-resolve": "^7.1.1",
"@testcafe/publish-please": "^5.6.0",
"@types/callsite": "^1.0.30",
"@types/chai": "^3.5.2",
"@types/debug": "^4.1.5",
Expand Down Expand Up @@ -221,7 +223,6 @@
"multer": "1.4.4-lts.1",
"openssl-self-signed-certificate": "^1.1.6",
"proxyquire": "^2.1.0",
"@testcafe/publish-please": "^5.6.0",
"react": "^16.13.1",
"recursive-copy": "^2.0.5",
"rollup": "2.16.1",
Expand Down
1 change: 1 addition & 0 deletions src/compiler/babel/load-libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,6 @@ export default function loadLibs ({ esm } = {}) {
presetReact: getPresetReact(),
proposalPrivateMethods: [require('@babel/plugin-proposal-private-methods'), { loose: true }],
proposalClassProperties: [require('@babel/plugin-proposal-class-properties'), { loose: true }],
transformClassStaticBlock: require('@babel/plugin-transform-class-static-block'),
};
}
3 changes: 2 additions & 1 deletion src/compiler/test-file/formats/es-next/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ export default class ESNextTestFileCompiler extends APIBasedTestFileCompilerBase
moduleResolver,
proposalPrivateMethods,
proposalClassProperties,
transformClassStaticBlock,
} = loadBabelLibs({ esm });

const opts = Object.assign({}, BASE_BABEL_OPTIONS, {
presets: [presetStage2, presetEnvForTestCode, presetReact],
plugins: [transformRuntime, moduleResolver, proposalPrivateMethods, proposalClassProperties],
plugins: [transformRuntime, moduleResolver, proposalPrivateMethods, proposalClassProperties, transformClassStaticBlock],
sourceMaps: 'inline',
filename,
});
Expand Down
18 changes: 18 additions & 0 deletions test/server/compiler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,24 @@ describe('Compiler', function () {
expect(results.inventory).to.equal('42 yoyo');
});
});

it('Should compile test with static class blocks', function () {
const sources = [
'test/server/data/test-suites/basic/testfile5.js',
];

return compile(sources)
.then(function (compiled) {
const tests = compiled.tests;
const fixtures = compiled.fixtures;

expect(tests.length).eql(1);
expect(fixtures.length).eql(1);

expect(tests[0].name).eql('Fixture6Test1');
expect(fixtures[0].name).eql('Fixture6');
});
});
});

describe('TypeScript', function () {
Expand Down
5 changes: 5 additions & 0 deletions test/server/data/test-suites/basic/dep3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ClassThatUsesStatic {
static { this.foo = true; }
}

export default ClassThatUsesStatic;
7 changes: 7 additions & 0 deletions test/server/data/test-suites/basic/testfile5.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import ClassThatUsesStatic from './dep3.js';

fixture('Fixture6');

test('Fixture6Test1', async () => {
ClassThatUsesStatic.foo;
});
Loading