Skip to content

Commit

Permalink
fix: strip comments for JSX pragma (#29145)
Browse files Browse the repository at this point in the history
* fix: strip comments for JSX pragma

* changelog for @fluentui/react-jsx-runtime
  • Loading branch information
layershifter committed Sep 14, 2023
1 parent 3bf2de9 commit bad33fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "fix: strip comments for JSX pragma",
"packageName": "@fluentui/react-jsx-runtime",
"email": "olfedias@microsoft.com",
"dependentChangeType": "patch"
}
7 changes: 6 additions & 1 deletion scripts/tasks/src/swc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,19 @@ async function swcTransform(options: Options) {
outputPath,
});

// Strip @jsx comments, see https://github.com/microsoft/fluentui/issues/29126
const resultCode = result.code
.replace('/** @jsxRuntime automatic */', '')
.replace('/** @jsxImportSource @fluentui/react-jsx-runtime */', '');

const compiledFilePath = path.resolve(packageRoot, fileName.replace(`${sourceRootDirName}`, outputPath));

//Create directory folder for new compiled file(s) to live in.
await fs.promises.mkdir(compiledFilePath.replace(path.basename(compiledFilePath), ''), { recursive: true });

const compiledFilePathJS = `${compiledFilePath.replace(tsFileExtensionRegex, '.js')}`;

await fs.promises.writeFile(compiledFilePathJS, result.code);
await fs.promises.writeFile(compiledFilePathJS, resultCode);
if (result.map) {
await fs.promises.writeFile(`${compiledFilePathJS}.map`, result.map);
}
Expand Down

0 comments on commit bad33fa

Please sign in to comment.