-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from bloczjs/fix-exports
[exports] use lib folder instead of dist folder + fix esm
- Loading branch information
Showing
5 changed files
with
73 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,10 +9,13 @@ | |
"module": "lib/react-responsive.modern.js", | ||
"types": "lib/index.d.ts", | ||
"exports": { | ||
"require": "./dist/react-responsive.js", | ||
"import": "./dist/react-responsive.modern.js", | ||
"browser": "./dist/react-responsive.modern.js", | ||
"umd": "./dist/react-responsive.umd.js" | ||
".": { | ||
"require": "./lib/react-responsive.js", | ||
"import": "./lib/react-responsive.modern.mjs", | ||
"browser": "./lib/react-responsive.modern.js", | ||
"umd": "./lib/react-responsive.umd.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"repository": "[email protected]:bloczjs/react-responsive.git", | ||
"keywords": [ | ||
|
@@ -28,7 +31,7 @@ | |
"license": "MIT", | ||
"bugs": "https://github.com/bloczjs/react-responsive/issues", | ||
"scripts": { | ||
"build": "yarn -s build:microbundle", | ||
"build": "yarn -s build:microbundle && cp lib/react-responsive.modern.js lib/react-responsive.modern.mjs", | ||
"build:dev": "yarn -s build:microbundle --compress false", | ||
"build:microbundle": "microbundle --name $npm_package_name --globals react=React", | ||
"link:readme": "rm ../../README.md && ln -s packages/react-responsive/README.md ../..", | ||
|
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,4 @@ | ||
import * as ReactResponsive from "@blocz/react-responsive"; | ||
import packageJSON from "@blocz/react-responsive/package.json"; | ||
|
||
console.log("Didn’t crash"); |
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,51 @@ | ||
import { execSync } from "child_process"; | ||
|
||
describe("Important files should be resolvable", () => { | ||
it("should work in a CJS context", () => { | ||
expect( | ||
require.resolve("@blocz/react-responsive"), | ||
).not.toBeNull(); | ||
expect( | ||
require.resolve( | ||
"@blocz/react-responsive/package.json", | ||
), | ||
).not.toBeNull(); | ||
}); | ||
|
||
it("should work in a ESM context", () => { | ||
expect( | ||
execSync( | ||
"node --experimental-json-modules ./esm.mjs", | ||
{ | ||
cwd: __dirname, | ||
encoding: "utf-8", | ||
}, | ||
), | ||
).toBe("Didn’t crash\n"); | ||
}); | ||
}); | ||
|
||
describe("built files", () => { | ||
it("should contain all necessary files", () => { | ||
expect( | ||
require.resolve( | ||
"@blocz/react-responsive/lib/react-responsive.js", | ||
), | ||
).not.toBeNull(); | ||
expect( | ||
require.resolve( | ||
"@blocz/react-responsive/lib/react-responsive.modern.js", | ||
), | ||
).not.toBeNull(); | ||
expect( | ||
require.resolve( | ||
"@blocz/react-responsive/lib/react-responsive.modern.mjs", | ||
), | ||
).not.toBeNull(); | ||
expect( | ||
require.resolve( | ||
"@blocz/react-responsive/lib/react-responsive.umd.js", | ||
), | ||
).not.toBeNull(); | ||
}); | ||
}); |
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