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

Cannot import "exports": { "module": ... } configured packages, instead we could get an error: Cannot use import statement outside a module #9071

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Expand Up @@ -388,6 +388,7 @@
- lukasgerm
- LukeAskew
- lukeshiru
- LumaKernel
- m0nica
- m5r
- machour
Expand Down
40 changes: 24 additions & 16 deletions integration/bug-report-test.ts
Expand Up @@ -59,29 +59,37 @@ test.beforeAll(async () => {
////////////////////////////////////////////////////////////////////////////
files: {
"app/routes/_index.tsx": js`
import { json } from "@remix-run/node";
import { useLoaderData, Link } from "@remix-run/react";

export function loader() {
return json("pizza");
}
import { myModule } from "my-module";

export default function Index() {
let data = useLoaderData();
return (
<div>
{data}
<Link to="/burgers">Other Route</Link>
{myModule}
</div>
)
}
`,

"app/routes/burgers.tsx": js`
export default function Index() {
return <div>cheeseburger</div>;
// NOTE: If "type": "module", is added, this test passes
"node_modules/my-module/package.json": `
{
"name": "my-module",
"version": "1.0.0",
"main": "main.js",
"exports": {
".": {
"require": "./main.js",
"import": "./main.esm.js"
}
}
}
`,
"node_modules/my-module/main.esm.js": js`
export const myModule = "hello from esm";
`,
"node_modules/my-module/main.js": js`
exports.myModule = "hello from cjs";
`,
},
});

Expand All @@ -98,16 +106,16 @@ test.afterAll(() => {
// add a good description for what you expect Remix to do 👇🏽
////////////////////////////////////////////////////////////////////////////////

test("[description of what you expect it to do]", async ({ page }) => {
test("Can be built and works", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
// You can test any request your app might get using `fixture`.
let response = await fixture.requestDocument("/");
expect(await response.text()).toMatch("pizza");
expect(await response.text()).toMatch("hello from esm");

// If you need to test interactivity use the `app`
await app.goto("/");
await app.clickLink("/burgers");
await page.waitForSelector("text=cheeseburger");
// await app.clickLink("/burgers");
// await page.waitForSelector("text=cheeseburger");

// If you're not sure what's going on, you can "poke" the app, it'll
// automatically open up in your browser for 20 seconds, so be quick!
Expand Down