Skip to content

Commit bc63ccd

Browse files
committed
init
1 parent 0638b34 commit bc63ccd

File tree

13 files changed

+5116
-0
lines changed

13 files changed

+5116
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
lib
2+
13
# Logs
24
logs
35
*.log

.idea/.gitignore

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/swc-plugin-transform-jsx-list.iml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

__tests__/usage.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const swc = require('@swc/core')
2+
const path = require('path')
3+
const fs = require('fs');
4+
const JSXConditionTransformPlugin = require(path.join(__dirname, '../lib/index.js')).default;
5+
6+
describe('', () => {
7+
const fixturesDir = path.join(__dirname, '__fixtures__');
8+
fs.readdirSync(fixturesDir).map((caseName) => {
9+
it(`should ${caseName.split('-').join(' ')}`, () => {
10+
const fixtureDir = path.join(fixturesDir, caseName);
11+
const actualPath = path.join(fixtureDir, 'actual.js');
12+
const actualCode = fs.readFileSync(actualPath, {encoding: 'utf-8'});
13+
const expectedCode = fs.readFileSync(path.join(fixtureDir, 'expected.js'), { encoding: 'utf-8' });
14+
15+
const transformedOutput = swc.transformSync(actualCode, {
16+
jsc: {
17+
parser: {
18+
jsx: true
19+
},
20+
},
21+
plugin: JSXConditionTransformPlugin
22+
});
23+
24+
expect(transformedOutput.code.trim()).toBe(expectedCode.trim());
25+
});
26+
});
27+
});

jest.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Sync object
2+
/** @type {import('@jest/types').Config.InitialOptions} */
3+
const config = {
4+
verbose: true,
5+
testMatch: ['!**/__fixtures__/**', '**/__tests__/**/*.js']
6+
};
7+
8+
module.exports = config;

0 commit comments

Comments
 (0)