Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kraenhansen committed Jun 9, 2023
1 parent 511bd95 commit a7a2158
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
43 changes: 43 additions & 0 deletions packages/realm/scripts/fix-dist-filenames.ts
@@ -0,0 +1,43 @@
////////////////////////////////////////////////////////////////////////////
//
// Copyright 2023 Realm Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
////////////////////////////////////////////////////////////////////////////

/* eslint-disable no-console */

import fs from "node:fs";
import path from "node:path";

const DIST_PATH = path.resolve(__dirname, "../dist");

console.log(`Running post build script to work around https://github.com/microsoft/TypeScript/issues/54573`);

function fixFilesInDirectory(...segments: string[]) {
for (const dirent of fs.readdirSync(path.join(...segments), { withFileTypes: true })) {
if (dirent.isFile()) {
const updatedName = dirent.name.replaceAll(".mjs", ".cjs").replaceAll(".mts", ".cts");
if (updatedName !== dirent.name) {
// Move the file
console.log(`Renaming ${dirent.name}${updatedName}`);
fs.renameSync(path.resolve(...segments, dirent.name), path.resolve(...segments, updatedName));
}
} else if (dirent.isDirectory()) {
fixFilesInDirectory(...segments, dirent.name);
}
}
}

fixFilesInDirectory(DIST_PATH);
7 changes: 7 additions & 0 deletions packages/realm/scripts/tsconfig.json
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"target": "ES2022",
"module": "Node16",
"moduleResolution": "node"
}
}

0 comments on commit a7a2158

Please sign in to comment.