This repository has been archived by the owner on Mar 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 365
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): babel preset-react 参数支持可配置
- Loading branch information
谢仁洪
committed
Apr 14, 2021
1 parent
db0e398
commit 5bf3050
Showing
6 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testPathIgnorePatterns: ['/esm/', '/cjs/'], | ||
testRegex: '.*\\.test\\.tsx?$', | ||
coveragePathIgnorePatterns: ['/src/__tests__/'], | ||
globals: { | ||
'ts-jest': { | ||
isolatedModules: true, | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { transformSync } from '@babel/core'; | ||
import preset from './index'; | ||
|
||
test('react default', () => { | ||
const code = transformSync( | ||
` | ||
import React from 'react' | ||
import { View } from '@remax/one' | ||
function Demo() { | ||
return <View>demo</View> | ||
} | ||
`.trim(), | ||
{ | ||
filename: 'file.tsx', | ||
babelrc: false, | ||
presets: [preset], | ||
} | ||
)!.code; | ||
|
||
expect(code).toMatch(`/*#__PURE__*/_react.default.createElement(_one.View, null, "demo")`); | ||
}); | ||
|
||
test('react options', () => { | ||
const code = transformSync( | ||
` | ||
import React from 'react' | ||
import { View } from '@remax/one' | ||
function Demo() { | ||
return <View>demo</View> | ||
} | ||
`.trim(), | ||
{ | ||
filename: 'file.tsx', | ||
babelrc: false, | ||
presets: [[preset, { react: { development: true } }]], | ||
} | ||
)!.code; | ||
|
||
expect(code).toMatch(`return /*#__PURE__*/_react.default.createElement(_one.View, {`); | ||
expect(code).toMatch(`__self: this,`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters