Skip to content

Commit

Permalink
Fix: more loosened React lib version check (#7484)
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinyaigeek committed Dec 28, 2021
1 parent 5a90199 commit 26570dc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
@@ -0,0 +1 @@
module.exports = <div />;
@@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"preact": "https://pkg.csb.dev/preactjs/preact/commit/96082866/preact"
}
}
9 changes: 9 additions & 0 deletions packages/core/integration-tests/test/transpilation.js
Expand Up @@ -130,6 +130,15 @@ describe('transpilation', function () {
assert(file.includes('h("div"'));
});

it('should support compiling JSX in JS files with Preact url dependency', async function () {
await bundle(
path.join(__dirname, '/integration/jsx-preact-with-url/index.js'),
);

let file = await outputFS.readFile(path.join(distDir, 'index.js'), 'utf8');
assert(file.includes('h("div"'));
});

it('should support compiling JSX in TS files with Preact dependency', async function () {
let b = await bundle(
path.join(__dirname, '/integration/jsx-preact-ts/index.tsx'),
Expand Down
5 changes: 4 additions & 1 deletion packages/transformers/js/src/JSTransformer.js
Expand Up @@ -209,8 +209,11 @@ export default (new Transformer({
pkg?.dependencies?.[effectiveReactLib] ||
pkg?.devDependencies?.[effectiveReactLib] ||
pkg?.peerDependencies?.[effectiveReactLib];
reactLibVersion = reactLibVersion
? semver.validRange(reactLibVersion)
: null;
let minReactLibVersion =
reactLibVersion != null && reactLibVersion !== '*'
reactLibVersion !== null && reactLibVersion !== '*'
? semver.minVersion(reactLibVersion)?.toString()
: null;

Expand Down

0 comments on commit 26570dc

Please sign in to comment.