From c43fdb0769a6acdbfb632d53cdfb1cfc11b18563 Mon Sep 17 00:00:00 2001 From: "chiawei.tcw" Date: Sat, 21 Apr 2018 12:46:31 +0800 Subject: [PATCH] fix #56, #57 support electron without network --- examples/browser-example/package.json | 2 +- examples/node-js-example/package.json | 2 +- package.json | 3 ++- rollup.config.js | 3 ++- src/index.js | 3 ++- 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/browser-example/package.json b/examples/browser-example/package.json index 8825e94..5f42a90 100644 --- a/examples/browser-example/package.json +++ b/examples/browser-example/package.json @@ -8,7 +8,7 @@ "react-scripts": "0.8.4" }, "dependencies": { - "react-intl-universal": "^1.7.2", + "react-intl-universal": "*", "axios": "^0.16.1", "lodash": "^4.17.4", "react": "^15.5.4", diff --git a/examples/node-js-example/package.json b/examples/node-js-example/package.json index ebed9bd..220a8f2 100644 --- a/examples/node-js-example/package.json +++ b/examples/node-js-example/package.json @@ -8,7 +8,7 @@ "react-scripts": "^0.9.0" }, "dependencies": { - "react-intl-universal": "^1.7.2", + "react-intl-universal": "*", "react": "^15.5.4", "react-dom": "^15.5.4" }, diff --git a/package.json b/package.json index 331307e..fd33858 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-intl-universal", - "version": "1.9.3", + "version": "1.10.1", "description": "Internationalize React apps. Not only for React.Component but also for Vanilla JS.", "keywords": [ "intl", @@ -33,6 +33,7 @@ "intl": "^1.2.5", "intl-messageformat": "^2.2.0", "invariant": "^2.2.2", + "is-electron": "^2.1.0", "load-script": "^1.0.0", "lodash.merge": "^4.6.1", "object-keys": "^1.0.11", diff --git a/rollup.config.js b/rollup.config.js index 1bf84f5..f1be027 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -28,7 +28,8 @@ export default { 'querystring', 'react', 'console-polyfill', - 'lodash.merge' + 'lodash.merge', + 'is-electron' ], plugins : [babel({exclude: 'node_modules/**', presets: ['es2015-rollup']})] }; diff --git a/src/index.js b/src/index.js index 6c30f59..a2ef2ad 100644 --- a/src/index.js +++ b/src/index.js @@ -9,6 +9,7 @@ import invariant from "invariant"; import "console-polyfill"; import * as constants from "./constants"; import merge from "lodash.merge"; +import isElectron from 'is-electron'; const COMMON_LOCALE_DATA_URLS = { en: "https://g.alicdn.com/react-intl-universal/locale-data/1.0.0/en.js", @@ -24,7 +25,7 @@ const COMMON_LOCALE_DATA_URLS = { }; -const isBrowser = typeof window !== "undefined"; +const isBrowser = !isElectron() && typeof window !== "undefined"; String.prototype.defaultMessage = String.prototype.d = function (msg) { return this || msg || "";