Skip to content

Commit

Permalink
Fix react-native build (#372)
Browse files Browse the repository at this point in the history
* Fix react-native build

* Fine tune RN build
  • Loading branch information
perry-mitchell authored Apr 21, 2024
1 parent 17059d9 commit 170e6ea
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 62 deletions.
60 changes: 24 additions & 36 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"md5": "^2.3.0",
"minimatch": "^7.4.6",
"nested-property": "^4.0.0",
"node-fetch": "^3.3.2",
"path-posix": "^1.0.0",
"url-join": "^5.0.0",
"url-parse": "^1.5.10"
Expand All @@ -87,7 +88,7 @@
"@types/chai": "^4.3.12",
"@types/he": "^1.2.3",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.28",
"@types/node": "^20.12.7",
"@types/sinon": "^17.0.3",
"@types/url-parse": "^1.4.11",
"babel-loader": "^9.1.3",
Expand All @@ -112,7 +113,6 @@
"mkdirp": "^1.0.4",
"mocha": "^10.3.0",
"nock": "^13.5.4",
"node-fetch": "^3.3.0",
"nodemon": "^3.1.0",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
Expand All @@ -121,7 +121,7 @@
"rimraf": "^5.0.5",
"sinon": "^17.0.1",
"ts-node": "^10.9.2",
"typescript": "^5.4.2",
"typescript": "^5.4.5",
"wait-on": "^6.0.1",
"webdav-server": "^2.6.2",
"webpack": "^5.90.3",
Expand Down
2 changes: 1 addition & 1 deletion source/operations/copyFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { joinURL } from "../tools/url.js";
import { encodePath } from "../tools/path.js";
import { request, prepareRequestOptions } from "../request.js";
import { handleResponseCode } from "../response.js";
import { CopyFileOptions, WebDAVClientContext, WebDAVMethodOptions } from "../types.js";
import { CopyFileOptions, WebDAVClientContext } from "../types.js";

export async function copyFile(
context: WebDAVClientContext,
Expand Down
2 changes: 1 addition & 1 deletion source/operations/moveFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { joinURL } from "../tools/url.js";
import { encodePath } from "../tools/path.js";
import { request, prepareRequestOptions } from "../request.js";
import { handleResponseCode } from "../response.js";
import { MoveFileOptions, WebDAVClientContext, WebDAVMethodOptions } from "../types.js";
import { MoveFileOptions, WebDAVClientContext } from "../types.js";

export async function moveFile(
context: WebDAVClientContext,
Expand Down
5 changes: 2 additions & 3 deletions source/operations/partialUpdateFileContents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Readable } from "node:stream";
import { Readable } from "stream";
import { Layerr } from "layerr";
import { joinURL } from "../tools/url.js";
import { encodePath } from "../tools/path.js";
Expand All @@ -10,8 +10,7 @@ import {
ErrorCode,
Headers,
WebDAVMethodOptions,
WebDAVClientContext,
WebDAVClientError
WebDAVClientContext
} from "../types.js";

export async function partialUpdateFileContents(
Expand Down
6 changes: 2 additions & 4 deletions source/tools/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ function getParser(): XMLParser {
hex: true,
leadingZeros: false
}
// // We don't use the processors here as decoding is done manually
// // later on - decoding early would break some path checks.
// attributeValueProcessor: val => decodeHTMLEntities(decodeURIComponent(val)),
// tagValueProcessor: val => decodeHTMLEntities(decodeURIComponent(val))
// We don't use the processors here as decoding is done manually
// later on - decoding early would break some path checks.
});
}

Expand Down
1 change: 1 addition & 0 deletions util/node-fetch.stub.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export { Headers, Request, Response } from "node-fetch";
export default () => {};
30 changes: 16 additions & 14 deletions webpack.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,15 @@ function getBasicConfig() {
loader: "babel-loader",
options: {
presets: [
["@babel/preset-env", {
targets: [
"> 0.25%, not dead",
"maintained node versions"
]
}],
[
"@babel/preset-env",
{
targets: ["> 0.25%, not dead", "maintained node versions"]
}
],
"@babel/preset-typescript"
],
plugins: [
"babel-plugin-transform-async-to-promises"
]
plugins: ["babel-plugin-transform-async-to-promises"]
},
resolve: {
fullySpecified: false
Expand All @@ -52,7 +50,8 @@ function getBasicConfig() {

resolve: {
alias: {
"http": path.resolve(__dirname, "./util/http.stub.ts"),
// http: path.resolve(__dirname, "./util/http.stub.ts"),
// https: path.resolve(__dirname, "./util/http.stub.ts")
"node-fetch": path.resolve(__dirname, "./util/node-fetch.stub.ts")
},
extensions: [".js"],
Expand Down Expand Up @@ -89,7 +88,7 @@ module.exports = [

resolve: {
alias: {
"he": path.resolve(__dirname, "./util/he.stub.ts")
he: path.resolve(__dirname, "./util/he.stub.ts")
},
plugins: [
// Handle .ts => .js resolution
Expand All @@ -102,9 +101,12 @@ module.exports = [
merge(getBasicConfig(), {
entry: path.resolve(__dirname, "./source/index.ts"),

externals: ["he"],

output: {
filename: "index.js",
path: path.resolve(__dirname, "./dist/react-native")
path: path.resolve(__dirname, "./dist/react-native"),
chunkFormat: "commonjs"
},

plugins: [
Expand All @@ -120,6 +122,6 @@ module.exports = [
]
},

target: "web"
}),
target: "node"
})
];

0 comments on commit 170e6ea

Please sign in to comment.