diff --git a/test/e2e/app-dir/non-root-project-monorepo/apps/web/app/import-meta-url-rsc/page.tsx b/test/e2e/app-dir/non-root-project-monorepo/apps/web/app/import-meta-url-rsc/page.tsx new file mode 100644 index 0000000000000..2da3517bb8457 --- /dev/null +++ b/test/e2e/app-dir/non-root-project-monorepo/apps/web/app/import-meta-url-rsc/page.tsx @@ -0,0 +1,5 @@ +const text = import.meta.url + +export default function Page() { + return

{text}

+} diff --git a/test/e2e/app-dir/non-root-project-monorepo/apps/web/app/import-meta-url-ssr/page.tsx b/test/e2e/app-dir/non-root-project-monorepo/apps/web/app/import-meta-url-ssr/page.tsx new file mode 100644 index 0000000000000..0d2eda39a7042 --- /dev/null +++ b/test/e2e/app-dir/non-root-project-monorepo/apps/web/app/import-meta-url-ssr/page.tsx @@ -0,0 +1,7 @@ +'use client' + +const text = import.meta.url + +export default function Page() { + return

{text}

+} diff --git a/test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts b/test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts index 375bc068cb480..9f211a846eb1e 100644 --- a/test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts +++ b/test/e2e/app-dir/non-root-project-monorepo/non-root-project-monorepo.test.ts @@ -48,6 +48,38 @@ describe('non-root-project-monorepo', () => { }) }) + describe('import.meta.url', () => { + it('should work during RSC', async () => { + const $ = await next.render$('/import-meta-url-rsc') + expect($('p').text()).toMatch( + /^file:\/\/.*\/next-install-[^/]+\/apps\/web\/app\/import-meta-url-rsc\/page.tsx$/ + ) + }) + + it('should work during SSR', async () => { + const $ = await next.render$('/import-meta-url-ssr') + expect($('p').text()).toMatch( + /^file:\/\/.*\/next-install-[^/]+\/apps\/web\/app\/import-meta-url-ssr\/page.tsx$/ + ) + }) + + it('should work on client-side', async () => { + const browser = await next.browser('/import-meta-url-ssr') + await assertNoRedbox(browser) + if (isTurbopack) { + // Turbopack intentionally doesn't expose the full path to the browser bundles + expect(await browser.elementByCss('p').text()).toBe( + 'file:///ROOT/apps/web/app/import-meta-url-ssr/page.tsx' + ) + } else { + expect(await browser.elementByCss('p').text()).toMatch( + /^file:\/\/.*\/next-install-[^/]+\/apps\/web\/app\/import-meta-url-ssr\/page.tsx$/ + ) + } + await browser.close() + }) + }) + if (isNextDev) { describe('source-maps', () => { function normalizeStackTrace(stack: string): string {