Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/bundler-plugins/src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export function createComponentNameAnnotateHooks(ignoredComponents: string[], in
const result = await transformAsync(code, {
plugins: [[plugin, { ignoredComponents }]],
filename: id,
sourceFileName: idWithoutQueryAndHash,
parserOpts: {
sourceType: 'module',
allowAwaitOutsideFunction: true,
Expand Down
16 changes: 15 additions & 1 deletion packages/bundler-plugins/test/core/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
import { getDebugIdSnippet } from '../../src/core';
import { createComponentNameAnnotateHooks, getDebugIdSnippet } from '../../src/core';
import { containsOnlyImports } from '../../src/core/utils';
import { describe, it, expect } from 'vitest';

describe('createComponentNameAnnotateHooks', () => {
it.each([
['.tsx', '/project/src/shared/providers/AppProviders.tsx'],
['.jsx', '/project/src/shared/providers/AppProviders.jsx'],
])('preserves the full file path in the emitted source map (%s)', async (_ext, id) => {
const { transform } = createComponentNameAnnotateHooks([], false);
const code = 'export function AppProviders() {\n return <div>hello</div>;\n}\n';

const result = await transform(code, id);

expect(result?.map?.sources).toEqual([id]);
});
});

describe('getDebugIdSnippet', () => {
it('returns the debugId injection snippet for a passed debugId', () => {
const snippet = getDebugIdSnippet('1234');
Expand Down
Loading