Skip to content

Commit cd04714

Browse files
committed
Fix sourcemap paths
1 parent 1872683 commit cd04714

File tree

4 files changed

+189
-10
lines changed

4 files changed

+189
-10
lines changed

move-react.js

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
const path = require("path")
22
const fs = require("fs")
33
const fsExtra = require('fs-extra')
4-
const replaceInFileSync = (file,from,to) => {
4+
5+
const replaceInFileSync = (file, from, to) => {
56
const data = fs.readFileSync(file, 'utf8');
6-
const newData = data.replace(from, to)
7-
fs.writeFileSync(file, newData, {encoding:"utf8"})
7+
const newData = data.replace(new RegExp(from, 'g'), to);
8+
fs.writeFileSync(file, newData, { encoding: "utf8" });
89
}
910

1011

@@ -55,6 +56,11 @@ files.forEach((fileName)=>{
5556
replaceInFileSync(path.join(__dirname, "lib/flagsmith/index.js.map"),"../../../flagsmith-core.ts","./src/flagsmith-core.ts" )
5657
replaceInFileSync(path.join(__dirname, "lib/flagsmith/index.js.map"),"../../../index.ts","./src/index.ts" )
5758
replaceInFileSync(path.join(__dirname, "lib/flagsmith/index.js.map"),"../../../utils","./src/utils" )
59+
replaceInFileSync(path.join(__dirname, "lib/flagsmith-es/index.js.map"),"../../../utils","./src/utils" )
60+
replaceInFileSync(path.join(__dirname, "lib/react-native-flagsmith/index.js.map"),"../../../utils","./src/utils" )
61+
replaceInFileSync(path.join(__dirname, "lib/flagsmith/react.js.map"),"../../../utils","./src/utils" )
62+
replaceInFileSync(path.join(__dirname, "lib/flagsmith-es/react.js.map"),"../../../utils","./src/utils" )
63+
replaceInFileSync(path.join(__dirname, "lib/react-native-flagsmith/react.js.map"),"../../../utils","./src/utils" )
5864

5965
// fix paths in flagsmith-es/index.js sourcemaps
6066
replaceInFileSync(path.join(__dirname, "lib/flagsmith-es/index.js.map"),"../../../flagsmith-core.ts","./src/flagsmith-core.ts" )
@@ -140,7 +146,7 @@ function syncFolders(src, dest) {
140146
}
141147
}
142148

143-
console.log('Folders synchronized successfully!');
149+
console.log('Folders synchronized successfully!', src, dest);
144150
} catch (err) {
145151
console.error('Error synchronizing folders:', err);
146152
}

nodemon.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"watch": ["."],
3+
"ignore": ["node_modules", "lib", "examples"],
4+
"ext": "js,ts,tsx,json",
5+
"exec": "npm run bundle"
6+
}

package-lock.json

Lines changed: 165 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
"description": "Feature flagging to support continuous development",
44
"main": "./flagsmith/index.js",
55
"scripts": {
6-
"postinstall": "patch-package",
7-
"prepublish": "npx in-publish && npm run build || echo",
6+
"build": "npm run generatetypes && npm run bundle",
7+
"bundle": "rollup -c && node ./move-react.js",
88
"deploy": "npm run build && npm test && cd ./lib/flagsmith/ && npm publish && cd ../../lib/react-native-flagsmith && npm publish && cd ../../lib/flagsmith-es && npm publish",
99
"deploy:beta": "npm run build && npm test && cd ./lib/flagsmith/ && npm publish --tag beta && cd ../../lib/react-native-flagsmith && npm publish --tag beta && cd ../../lib/flagsmith-es && npm publish --tag beta",
10-
"bundle": "rollup -c && node ./move-react.js",
11-
"build": "npm run generatetypes && npm run bundle",
12-
"test": "jest --env=jsdom",
13-
"generatetypes": "curl https://raw.githubusercontent.com/Flagsmith/flagsmith/refs/heads/main/sdk/evaluation-context.json -o evaluation-context.json && npx quicktype -o evaluation-context.ts --src-lang schema --just-types --no-prefer-types --nice-property-names evaluation-context.json && rm evaluation-context.json"
10+
"dev": "nodemon",
11+
"generatetypes": "curl https://raw.githubusercontent.com/Flagsmith/flagsmith/refs/heads/main/sdk/evaluation-context.json -o evaluation-context.json && npx quicktype -o evaluation-context.ts --src-lang schema --just-types --no-prefer-types --nice-property-names evaluation-context.json && rm evaluation-context.json",
12+
"postinstall": "patch-package",
13+
"prepublish": "npx in-publish && npm run build || echo",
14+
"test": "jest --env=jsdom"
1415
},
1516
"repository": {
1617
"type": "git",
@@ -49,6 +50,7 @@
4950
"in-publish": "^2.0.1",
5051
"jest": "^29.7.0",
5152
"jest-environment-jsdom": "^29.7.0",
53+
"nodemon": "^3.1.7",
5254
"patch-package": "^6.5.0",
5355
"quicktype": "^23.0.170",
5456
"react": "^18.2.0",

0 commit comments

Comments
 (0)