Skip to content

fix: sourcemaps #271

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

Merged
merged 6 commits into from
Dec 18, 2024
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
2 changes: 1 addition & 1 deletion lib/flagsmith-es/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flagsmith-es",
"version": "8.0.0",
"version": "8.0.1",
"description": "Feature flagging to support continuous development. This is an esm equivalent of the standard flagsmith npm module.",
"main": "./index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion lib/flagsmith/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flagsmith",
"version": "8.0.0",
"version": "8.0.1",
"description": "Feature flagging to support continuous development",
"main": "./index.js",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion lib/react-native-flagsmith/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-flagsmith",
"version": "8.0.0",
"version": "8.0.1",
"description": "Feature flagging to support continuous development",
"main": "./index.js",
"repository": {
Expand Down
44 changes: 39 additions & 5 deletions move-react.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const path = require("path")
const fs = require("fs")
const fsExtra = require('fs-extra')

const replaceInFileSync = (file,from,to) => {
const replaceInFileSync = (file, from, to) => {
const data = fs.readFileSync(file, 'utf8');
const newData = data.replace(from, to)
fs.writeFileSync(file, newData, {encoding:"utf8"})
const newData = data.replace(new RegExp(from, 'g'), to);
fs.writeFileSync(file, newData, { encoding: "utf8" });
}


Expand Down Expand Up @@ -43,8 +44,6 @@ fs.copyFileSync(path.join(__dirname,"isomorphic-es.ts"),path.join(__dirname,"lib





const files= fs.readdirSync(path.join(__dirname, "lib/flagsmith"));
files.forEach((fileName)=>{
console.log(fileName)
Expand All @@ -56,6 +55,12 @@ files.forEach((fileName)=>{
// fix paths in flagsmith/index.js sourcemaps
replaceInFileSync(path.join(__dirname, "lib/flagsmith/index.js.map"),"../../../flagsmith-core.ts","./src/flagsmith-core.ts" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith/index.js.map"),"../../../index.ts","./src/index.ts" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith/index.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith-es/index.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/react-native-flagsmith/index.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith/react.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/flagsmith-es/react.js.map"),"../../../utils","./src/utils" )
replaceInFileSync(path.join(__dirname, "lib/react-native-flagsmith/react.js.map"),"../../../utils","./src/utils" )

// fix paths in flagsmith-es/index.js sourcemaps
replaceInFileSync(path.join(__dirname, "lib/flagsmith-es/index.js.map"),"../../../flagsmith-core.ts","./src/flagsmith-core.ts" )
Expand Down Expand Up @@ -121,3 +126,32 @@ try {
try {
fs.rmdirSync(path.join(__dirname,"lib/react-native-flagsmith/test"), {recursive:true})
} catch (e){}



function syncFolders(src, dest) {
try {
// Ensure the destination folder exists
fsExtra.ensureDirSync(dest);

const entries = fs.readdirSync(src, { withFileTypes: true });

for (const entry of entries) {
const srcPath = path.join(src, entry.name);
const destPath = path.join(dest, entry.name);

if (entry.isFile()) {
// Copy only files to the destination, overwriting existing files
fs.copyFileSync(srcPath, destPath);
}
}

console.log('Folders synchronized successfully!', src, dest);
} catch (err) {
console.error('Error synchronizing folders:', err);
}
}

syncFolders(path.join(__dirname,'utils'),path.join(__dirname,'lib/flagsmith/src/utils'))
syncFolders(path.join(__dirname,'utils'),path.join(__dirname,'lib/flagsmith-es/src/utils'))
syncFolders(path.join(__dirname,'utils'),path.join(__dirname,'lib/react-native-flagsmith/src/utils'))
6 changes: 6 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"watch": ["."],
"ignore": ["node_modules", "lib", "examples"],
"ext": "js,ts,tsx,json",
"exec": "npm run bundle"
}
Loading
Loading