From 074bb2d8d5b47789a06909b5c129f5a3c7143808 Mon Sep 17 00:00:00 2001 From: William Petit Date: Wed, 30 Jun 2021 15:14:00 +0200 Subject: [PATCH] Use webpack.NormalModuleReplacementPlugin to generate react-native bundle --- lib/converter.js | 6 +----- package-lock.json | 9 --------- package.json | 1 - webpack.common.js | 14 ++++++++------ 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/lib/converter.js b/lib/converter.js index d1ec839..f8c5549 100644 --- a/lib/converter.js +++ b/lib/converter.js @@ -1,9 +1,5 @@ -/// #if target == 'native' - import xml2js from 'react-native-xml2js'; -/// #else - import xml2js from 'xml2js'; -/// #endif +import xml2js from 'xml2js'; import { featureCollection } from '@turf/helpers'; import area from '@turf/area'; diff --git a/package-lock.json b/package-lock.json index 94bea6e..651fc51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3943,15 +3943,6 @@ "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==" }, - "ifdef-loader": { - "version": "2.1.5", - "resolved": "https://registry.npmjs.org/ifdef-loader/-/ifdef-loader-2.1.5.tgz", - "integrity": "sha512-GMUW5L8ZjsKRGABV3iXLdNFe2l7qFp9jeGYS55I6RNZLgQpicKxUfdH5oLDJ1cu+udb0hZiglwW6nX2kzgy86w==", - "dev": true, - "requires": { - "loader-utils": "^1.1.0" - } - }, "import-local": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.0.2.tgz", diff --git a/package.json b/package.json index 8912d78..79e6f2d 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ "babel-polyfill": "^6.26.0", "clean-webpack-plugin": "^3.0.0", "http-server": "^0.12.3", - "ifdef-loader": "^2.1.5", "jest": "^26.6.3", "ts-loader": "^8.0.11", "typescript": "^4.1.2", diff --git a/webpack.common.js b/webpack.common.js index fe2b853..84e64d2 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -14,8 +14,7 @@ module.exports = [ test: /\.(t|j)s$/, use: 'ts-loader', exclude: /node_modules/, - }, - { loader: "ifdef-loader", options: { target: "node" } }, + } ] }, resolve: { @@ -35,13 +34,17 @@ module.exports = [ test: /\.(t|j)s$/, use: 'ts-loader', exclude: /node_modules/, - }, - { loader: "ifdef-loader", options: { target: "native" } }, + } ] }, resolve: { extensions: ['*', '.ts', '.ts', '.js'] }, + plugins: [ + new webpack.NormalModuleReplacementPlugin( + /^xml2js$/, 'react-native-xml2js', + ), + ] }, { entry: { @@ -58,8 +61,7 @@ module.exports = [ test: /\.(t|j)s$/, use: 'ts-loader', exclude: /node_modules/, - }, - { loader: "ifdef-loader", options: { target: "browser" } }, + } ] }, resolve: {