From fdfc4a11f3951f7ed32fab7e35a77ea1bf206226 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yankouski Date: Wed, 4 Jul 2018 16:04:46 +0300 Subject: [PATCH 1/5] split to packages in accordance to specific library --- packages/kbn-i18n/.gitignore | 2 ++ .../{src/browser.js => aliases/angular.js} | 11 ++-------- packages/kbn-i18n/aliases/react.js | 21 +++++++++++++++++++ packages/kbn-i18n/package.json | 7 ++++--- packages/kbn-i18n/src/{ => core}/index.js | 6 +++--- 5 files changed, 32 insertions(+), 15 deletions(-) create mode 100644 packages/kbn-i18n/.gitignore rename packages/kbn-i18n/{src/browser.js => aliases/angular.js} (75%) create mode 100644 packages/kbn-i18n/aliases/react.js rename packages/kbn-i18n/src/{ => core}/index.js (87%) diff --git a/packages/kbn-i18n/.gitignore b/packages/kbn-i18n/.gitignore new file mode 100644 index 0000000000000..aa50f58317354 --- /dev/null +++ b/packages/kbn-i18n/.gitignore @@ -0,0 +1,2 @@ +/angular.js +/react.js diff --git a/packages/kbn-i18n/src/browser.js b/packages/kbn-i18n/aliases/angular.js similarity index 75% rename from packages/kbn-i18n/src/browser.js rename to packages/kbn-i18n/aliases/angular.js index 4f5c40dcfdcd2..da6d8894cc8f3 100644 --- a/packages/kbn-i18n/src/browser.js +++ b/packages/kbn-i18n/aliases/angular.js @@ -17,12 +17,5 @@ * under the License. */ -import * as angular from './angular'; -import * as react from './react'; -import * as i18nCore from './core/i18n'; - -export { formats } from './core/formats'; - -export const AngularI18n = angular; -export const ReactI18n = react; -export const i18n = i18nCore; +// eslint-disable-next-line import/no-unresolved +export * from './target/web/angular'; diff --git a/packages/kbn-i18n/aliases/react.js b/packages/kbn-i18n/aliases/react.js new file mode 100644 index 0000000000000..eeddce04056f3 --- /dev/null +++ b/packages/kbn-i18n/aliases/react.js @@ -0,0 +1,21 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +// eslint-disable-next-line import/no-unresolved +export * from './target/web/react'; diff --git a/packages/kbn-i18n/package.json b/packages/kbn-i18n/package.json index da276e01c8d33..3fe54662f441e 100644 --- a/packages/kbn-i18n/package.json +++ b/packages/kbn-i18n/package.json @@ -1,15 +1,16 @@ { "name": "@kbn/i18n", - "browser": "./target/web/browser.js", - "main": "./target/node/index.js", + "browser": "./target/web/core", + "main": "./target/node/core", "module": "./src/index.js", "version": "1.0.0", "license": "Apache-2.0", "private": true, "scripts": { - "build": "yarn build:web && yarn build:node", + "build": "yarn build:web && yarn build:node && yarn build:aliases", "build:web": "cross-env BABEL_ENV=web babel src --out-dir target/web", "build:node": "cross-env BABEL_ENV=node babel src --out-dir target/node", + "build:aliases": "cross-env BABEL_ENV=web babel aliases --out-dir .", "kbn:bootstrap": "yarn build", "kbn:watch": "yarn build --watch" }, diff --git a/packages/kbn-i18n/src/index.js b/packages/kbn-i18n/src/core/index.js similarity index 87% rename from packages/kbn-i18n/src/index.js rename to packages/kbn-i18n/src/core/index.js index 19619fc1c740a..9403980311da1 100644 --- a/packages/kbn-i18n/src/index.js +++ b/packages/kbn-i18n/src/core/index.js @@ -17,10 +17,10 @@ * under the License. */ -import * as i18nCore from './core/i18n'; -import * as loader from './core/loader'; +import * as i18nCore from './i18n'; +import * as loader from './loader'; -export { formats } from './core/formats'; +export { formats } from './formats'; export const i18n = i18nCore; export const i18nLoader = loader; From 17895989e1150297d545c8a70d3e07191020b15c Mon Sep 17 00:00:00 2001 From: Aliaksandr Yankouski Date: Fri, 6 Jul 2018 13:56:27 +0300 Subject: [PATCH 2/5] split to packages depending on tech and environment --- packages/kbn-i18n/.gitignore | 2 -- packages/kbn-i18n/README.md | 12 +++------- packages/kbn-i18n/angular/package.json | 4 ++++ packages/kbn-i18n/package.json | 8 +++---- packages/kbn-i18n/react/package.json | 4 ++++ .../kbn-i18n/src/core/{ => i18n}/formats.js | 0 .../kbn-i18n/src/core/{ => i18n}/helper.js | 0 packages/kbn-i18n/src/core/{ => i18n}/i18n.js | 0 .../react.js => src/core/i18n/index.js} | 4 ++-- .../core/i18n/intl_polyfill.js} | 5 +++-- .../kbn-i18n/src/core/{ => i18n}/locales.js | 0 packages/kbn-i18n/src/core/i18n/node.js | 22 +++++++++++++++++++ packages/kbn-i18n/src/core/i18n/package.json | 4 ++++ packages/kbn-i18n/src/core/index.js | 2 -- packages/kbn-i18n/src/core/loader.js | 2 +- packages/kbn-i18n/yarn.lock | 4 ++++ src/ui/public/i18n/index.js | 6 ++--- 17 files changed, 53 insertions(+), 26 deletions(-) delete mode 100644 packages/kbn-i18n/.gitignore create mode 100644 packages/kbn-i18n/angular/package.json create mode 100644 packages/kbn-i18n/react/package.json rename packages/kbn-i18n/src/core/{ => i18n}/formats.js (100%) rename packages/kbn-i18n/src/core/{ => i18n}/helper.js (100%) rename packages/kbn-i18n/src/core/{ => i18n}/i18n.js (100%) rename packages/kbn-i18n/{aliases/react.js => src/core/i18n/index.js} (90%) rename packages/kbn-i18n/{aliases/angular.js => src/core/i18n/intl_polyfill.js} (90%) rename packages/kbn-i18n/src/core/{ => i18n}/locales.js (100%) create mode 100644 packages/kbn-i18n/src/core/i18n/node.js create mode 100644 packages/kbn-i18n/src/core/i18n/package.json diff --git a/packages/kbn-i18n/.gitignore b/packages/kbn-i18n/.gitignore deleted file mode 100644 index aa50f58317354..0000000000000 --- a/packages/kbn-i18n/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/angular.js -/react.js diff --git a/packages/kbn-i18n/README.md b/packages/kbn-i18n/README.md index ff00cb1e837da..ddbc24ac152b4 100644 --- a/packages/kbn-i18n/README.md +++ b/packages/kbn-i18n/README.md @@ -192,9 +192,7 @@ uses I18n engine under the hood: ```js import React from 'react'; import ReactDOM from 'react-dom'; -import { ReactI18n } from '@kbn/i18n'; - -const { I18nProvider } = ReactI18n; +import { I18nProvider } from '@kbn/i18n/react'; ReactDOM.render( @@ -209,9 +207,7 @@ ReactDOM.render( After that we can use `FormattedMessage` components inside `RootComponent`: ```js import React, { Component } from 'react'; -import { ReactI18n } from '@kbn/i18n'; - -const { FormattedMessage } = ReactI18n; +import { FormattedMessage } from '@kbn/i18n/react'; class RootComponent extends Component { constructor(props) { @@ -261,9 +257,7 @@ should be a function that takes `intl` object into parameters: ```js import React from 'react'; -import { ReactI18n } from '@kbn/i18n'; - -const { I18nContext } = ReactI18n; +import { I18nContext } from '@kbn/i18n/react'; const MyComponent = () => ( diff --git a/packages/kbn-i18n/angular/package.json b/packages/kbn-i18n/angular/package.json new file mode 100644 index 0000000000000..1359539d4a867 --- /dev/null +++ b/packages/kbn-i18n/angular/package.json @@ -0,0 +1,4 @@ +{ + "browser": "../target/web/angular", + "main": "../target/node/angular" +} diff --git a/packages/kbn-i18n/package.json b/packages/kbn-i18n/package.json index 3fe54662f441e..196fdbbb341b1 100644 --- a/packages/kbn-i18n/package.json +++ b/packages/kbn-i18n/package.json @@ -7,10 +7,9 @@ "license": "Apache-2.0", "private": true, "scripts": { - "build": "yarn build:web && yarn build:node && yarn build:aliases", - "build:web": "cross-env BABEL_ENV=web babel src --out-dir target/web", - "build:node": "cross-env BABEL_ENV=node babel src --out-dir target/node", - "build:aliases": "cross-env BABEL_ENV=web babel aliases --out-dir .", + "build": "yarn build:web && yarn build:node", + "build:web": "cross-env BABEL_ENV=web babel src --out-dir target/web --copy-files", + "build:node": "cross-env BABEL_ENV=node babel src --out-dir target/node --copy-files", "kbn:bootstrap": "yarn build", "kbn:watch": "yarn build --watch" }, @@ -22,6 +21,7 @@ }, "dependencies": { "accept-language-parser": "^1.5.0", + "intl": "^1.2.5", "intl-format-cache": "^2.1.0", "intl-messageformat": "^2.2.0", "intl-relativeformat": "^2.1.0", diff --git a/packages/kbn-i18n/react/package.json b/packages/kbn-i18n/react/package.json new file mode 100644 index 0000000000000..73e591f8b1fc3 --- /dev/null +++ b/packages/kbn-i18n/react/package.json @@ -0,0 +1,4 @@ +{ + "browser": "../target/web/react", + "main": "../target/node/react" +} diff --git a/packages/kbn-i18n/src/core/formats.js b/packages/kbn-i18n/src/core/i18n/formats.js similarity index 100% rename from packages/kbn-i18n/src/core/formats.js rename to packages/kbn-i18n/src/core/i18n/formats.js diff --git a/packages/kbn-i18n/src/core/helper.js b/packages/kbn-i18n/src/core/i18n/helper.js similarity index 100% rename from packages/kbn-i18n/src/core/helper.js rename to packages/kbn-i18n/src/core/i18n/helper.js diff --git a/packages/kbn-i18n/src/core/i18n.js b/packages/kbn-i18n/src/core/i18n/i18n.js similarity index 100% rename from packages/kbn-i18n/src/core/i18n.js rename to packages/kbn-i18n/src/core/i18n/i18n.js diff --git a/packages/kbn-i18n/aliases/react.js b/packages/kbn-i18n/src/core/i18n/index.js similarity index 90% rename from packages/kbn-i18n/aliases/react.js rename to packages/kbn-i18n/src/core/i18n/index.js index eeddce04056f3..af7c854ad979d 100644 --- a/packages/kbn-i18n/aliases/react.js +++ b/packages/kbn-i18n/src/core/i18n/index.js @@ -17,5 +17,5 @@ * under the License. */ -// eslint-disable-next-line import/no-unresolved -export * from './target/web/react'; +export { formats } from './formats'; +export * from './i18n'; diff --git a/packages/kbn-i18n/aliases/angular.js b/packages/kbn-i18n/src/core/i18n/intl_polyfill.js similarity index 90% rename from packages/kbn-i18n/aliases/angular.js rename to packages/kbn-i18n/src/core/i18n/intl_polyfill.js index da6d8894cc8f3..f2ebe9c4725bc 100644 --- a/packages/kbn-i18n/aliases/angular.js +++ b/packages/kbn-i18n/src/core/i18n/intl_polyfill.js @@ -17,5 +17,6 @@ * under the License. */ -// eslint-disable-next-line import/no-unresolved -export * from './target/web/angular'; +import Intl from 'intl'; + +global.Intl = Intl; diff --git a/packages/kbn-i18n/src/core/locales.js b/packages/kbn-i18n/src/core/i18n/locales.js similarity index 100% rename from packages/kbn-i18n/src/core/locales.js rename to packages/kbn-i18n/src/core/i18n/locales.js diff --git a/packages/kbn-i18n/src/core/i18n/node.js b/packages/kbn-i18n/src/core/i18n/node.js new file mode 100644 index 0000000000000..fefc2a205d229 --- /dev/null +++ b/packages/kbn-i18n/src/core/i18n/node.js @@ -0,0 +1,22 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import './intl_polyfill'; + +export * from './index'; diff --git a/packages/kbn-i18n/src/core/i18n/package.json b/packages/kbn-i18n/src/core/i18n/package.json new file mode 100644 index 0000000000000..4ec0fb4158031 --- /dev/null +++ b/packages/kbn-i18n/src/core/i18n/package.json @@ -0,0 +1,4 @@ +{ + "browser": "./index.js", + "main": "./node.js" +} diff --git a/packages/kbn-i18n/src/core/index.js b/packages/kbn-i18n/src/core/index.js index 9403980311da1..0eeef8faa7dde 100644 --- a/packages/kbn-i18n/src/core/index.js +++ b/packages/kbn-i18n/src/core/index.js @@ -20,7 +20,5 @@ import * as i18nCore from './i18n'; import * as loader from './loader'; -export { formats } from './formats'; - export const i18n = i18nCore; export const i18nLoader = loader; diff --git a/packages/kbn-i18n/src/core/loader.js b/packages/kbn-i18n/src/core/loader.js index 2b45c5e890878..a88a9e6a3674a 100644 --- a/packages/kbn-i18n/src/core/loader.js +++ b/packages/kbn-i18n/src/core/loader.js @@ -29,7 +29,7 @@ import { readFile } from 'fs'; import { promisify } from 'util'; import { pick } from 'accept-language-parser'; import JSON5 from 'json5'; -import { unique } from './helper'; +import { unique } from './i18n/helper'; const asyncReadFile = promisify(readFile); diff --git a/packages/kbn-i18n/yarn.lock b/packages/kbn-i18n/yarn.lock index 820b3d356fa3c..4334bdb65678f 100644 --- a/packages/kbn-i18n/yarn.lock +++ b/packages/kbn-i18n/yarn.lock @@ -1053,6 +1053,10 @@ intl-relativeformat@^2.0.0, intl-relativeformat@^2.1.0: dependencies: intl-messageformat "^2.0.0" +intl@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/intl/-/intl-1.2.5.tgz#82244a2190c4e419f8371f5aa34daa3420e2abde" + invariant@^2.1.1, invariant@^2.2.2: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" diff --git a/src/ui/public/i18n/index.js b/src/ui/public/i18n/index.js index fe1062f1ae1ac..5c2c7f3f96c05 100644 --- a/src/ui/public/i18n/index.js +++ b/src/ui/public/i18n/index.js @@ -17,15 +17,13 @@ * under the License. */ -import { AngularI18n } from '@kbn/i18n'; import { uiModules } from 'ui/modules'; import { metadata } from 'ui/metadata'; - -const { +import { i18nProvider, i18nFilter, i18nDirective, -} = AngularI18n; +} from '@kbn/i18n/angular'; uiModules.get('i18n') .provider('i18n', i18nProvider) From 147fd863d594b9f2b1d161b3858276a1ceb8695a Mon Sep 17 00:00:00 2001 From: Aliaksandr Yankouski Date: Tue, 10 Jul 2018 10:39:01 +0300 Subject: [PATCH 3/5] make env modules names consistent --- packages/kbn-i18n/src/core/i18n/{node.js => browser.js} | 5 ++--- packages/kbn-i18n/src/core/i18n/index.js | 5 +++-- packages/kbn-i18n/src/core/i18n/package.json | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) rename packages/kbn-i18n/src/core/i18n/{node.js => browser.js} (92%) diff --git a/packages/kbn-i18n/src/core/i18n/node.js b/packages/kbn-i18n/src/core/i18n/browser.js similarity index 92% rename from packages/kbn-i18n/src/core/i18n/node.js rename to packages/kbn-i18n/src/core/i18n/browser.js index fefc2a205d229..af7c854ad979d 100644 --- a/packages/kbn-i18n/src/core/i18n/node.js +++ b/packages/kbn-i18n/src/core/i18n/browser.js @@ -17,6 +17,5 @@ * under the License. */ -import './intl_polyfill'; - -export * from './index'; +export { formats } from './formats'; +export * from './i18n'; diff --git a/packages/kbn-i18n/src/core/i18n/index.js b/packages/kbn-i18n/src/core/i18n/index.js index af7c854ad979d..451b02b670572 100644 --- a/packages/kbn-i18n/src/core/i18n/index.js +++ b/packages/kbn-i18n/src/core/i18n/index.js @@ -17,5 +17,6 @@ * under the License. */ -export { formats } from './formats'; -export * from './i18n'; +import './intl_polyfill'; + +export * from './browser'; diff --git a/packages/kbn-i18n/src/core/i18n/package.json b/packages/kbn-i18n/src/core/i18n/package.json index 4ec0fb4158031..7eacc60d3880b 100644 --- a/packages/kbn-i18n/src/core/i18n/package.json +++ b/packages/kbn-i18n/src/core/i18n/package.json @@ -1,4 +1,4 @@ { - "browser": "./index.js", - "main": "./node.js" + "browser": "./browser.js", + "main": "./index.js" } From 850548dbdda3beffab67ffa40e3ee85382859d91 Mon Sep 17 00:00:00 2001 From: Aliaksandr Yankouski Date: Tue, 10 Jul 2018 13:01:08 +0300 Subject: [PATCH 4/5] remove intl polyfilling --- packages/kbn-i18n/package.json | 5 ++--- packages/kbn-i18n/src/core/i18n/browser.js | 21 ------------------ packages/kbn-i18n/src/core/i18n/index.js | 5 ++--- .../kbn-i18n/src/core/i18n/intl_polyfill.js | 22 ------------------- packages/kbn-i18n/src/core/i18n/package.json | 4 ---- packages/kbn-i18n/yarn.lock | 4 ---- 6 files changed, 4 insertions(+), 57 deletions(-) delete mode 100644 packages/kbn-i18n/src/core/i18n/browser.js delete mode 100644 packages/kbn-i18n/src/core/i18n/intl_polyfill.js delete mode 100644 packages/kbn-i18n/src/core/i18n/package.json diff --git a/packages/kbn-i18n/package.json b/packages/kbn-i18n/package.json index 196fdbbb341b1..3ccb8d0149777 100644 --- a/packages/kbn-i18n/package.json +++ b/packages/kbn-i18n/package.json @@ -8,8 +8,8 @@ "private": true, "scripts": { "build": "yarn build:web && yarn build:node", - "build:web": "cross-env BABEL_ENV=web babel src --out-dir target/web --copy-files", - "build:node": "cross-env BABEL_ENV=node babel src --out-dir target/node --copy-files", + "build:web": "cross-env BABEL_ENV=web babel src --out-dir target/web", + "build:node": "cross-env BABEL_ENV=node babel src --out-dir target/node", "kbn:bootstrap": "yarn build", "kbn:watch": "yarn build --watch" }, @@ -21,7 +21,6 @@ }, "dependencies": { "accept-language-parser": "^1.5.0", - "intl": "^1.2.5", "intl-format-cache": "^2.1.0", "intl-messageformat": "^2.2.0", "intl-relativeformat": "^2.1.0", diff --git a/packages/kbn-i18n/src/core/i18n/browser.js b/packages/kbn-i18n/src/core/i18n/browser.js deleted file mode 100644 index af7c854ad979d..0000000000000 --- a/packages/kbn-i18n/src/core/i18n/browser.js +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -export { formats } from './formats'; -export * from './i18n'; diff --git a/packages/kbn-i18n/src/core/i18n/index.js b/packages/kbn-i18n/src/core/i18n/index.js index 451b02b670572..af7c854ad979d 100644 --- a/packages/kbn-i18n/src/core/i18n/index.js +++ b/packages/kbn-i18n/src/core/i18n/index.js @@ -17,6 +17,5 @@ * under the License. */ -import './intl_polyfill'; - -export * from './browser'; +export { formats } from './formats'; +export * from './i18n'; diff --git a/packages/kbn-i18n/src/core/i18n/intl_polyfill.js b/packages/kbn-i18n/src/core/i18n/intl_polyfill.js deleted file mode 100644 index f2ebe9c4725bc..0000000000000 --- a/packages/kbn-i18n/src/core/i18n/intl_polyfill.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import Intl from 'intl'; - -global.Intl = Intl; diff --git a/packages/kbn-i18n/src/core/i18n/package.json b/packages/kbn-i18n/src/core/i18n/package.json deleted file mode 100644 index 7eacc60d3880b..0000000000000 --- a/packages/kbn-i18n/src/core/i18n/package.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "browser": "./browser.js", - "main": "./index.js" -} diff --git a/packages/kbn-i18n/yarn.lock b/packages/kbn-i18n/yarn.lock index 4334bdb65678f..820b3d356fa3c 100644 --- a/packages/kbn-i18n/yarn.lock +++ b/packages/kbn-i18n/yarn.lock @@ -1053,10 +1053,6 @@ intl-relativeformat@^2.0.0, intl-relativeformat@^2.1.0: dependencies: intl-messageformat "^2.0.0" -intl@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/intl/-/intl-1.2.5.tgz#82244a2190c4e419f8371f5aa34daa3420e2abde" - invariant@^2.1.1, invariant@^2.2.2: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" From 4c236dbb4c11a3d97175ba9793ef4da08fcafeee Mon Sep 17 00:00:00 2001 From: yankouskia Date: Thu, 12 Jul 2018 10:38:00 +0300 Subject: [PATCH 5/5] move laoder to root, i18n folder to core --- packages/kbn-i18n/package.json | 4 ++-- packages/kbn-i18n/src/angular/provider.js | 2 +- packages/kbn-i18n/src/core/{i18n => }/formats.js | 0 packages/kbn-i18n/src/core/{i18n => }/helper.js | 0 packages/kbn-i18n/src/core/{i18n => }/i18n.js | 0 packages/kbn-i18n/src/core/index.js | 7 ++----- packages/kbn-i18n/src/core/{i18n => }/locales.js | 0 packages/kbn-i18n/src/{core/i18n => }/index.js | 7 +++++-- packages/kbn-i18n/src/{core => }/loader.js | 2 +- packages/kbn-i18n/src/react/provider.js | 2 +- 10 files changed, 12 insertions(+), 12 deletions(-) rename packages/kbn-i18n/src/core/{i18n => }/formats.js (100%) rename packages/kbn-i18n/src/core/{i18n => }/helper.js (100%) rename packages/kbn-i18n/src/core/{i18n => }/i18n.js (100%) rename packages/kbn-i18n/src/core/{i18n => }/locales.js (100%) rename packages/kbn-i18n/src/{core/i18n => }/index.js (85%) rename packages/kbn-i18n/src/{core => }/loader.js (99%) diff --git a/packages/kbn-i18n/package.json b/packages/kbn-i18n/package.json index 3ccb8d0149777..2c00f44564bf8 100644 --- a/packages/kbn-i18n/package.json +++ b/packages/kbn-i18n/package.json @@ -1,7 +1,7 @@ { "name": "@kbn/i18n", - "browser": "./target/web/core", - "main": "./target/node/core", + "browser": "./target/web", + "main": "./target/node", "module": "./src/index.js", "version": "1.0.0", "license": "Apache-2.0", diff --git a/packages/kbn-i18n/src/angular/provider.js b/packages/kbn-i18n/src/angular/provider.js index 97fd160cc3554..e4f73b7de0db3 100644 --- a/packages/kbn-i18n/src/angular/provider.js +++ b/packages/kbn-i18n/src/angular/provider.js @@ -17,7 +17,7 @@ * under the License. */ -import * as i18n from '../core/i18n'; +import * as i18n from '../core'; export function i18nProvider() { this.addMessages = i18n.addMessages; diff --git a/packages/kbn-i18n/src/core/i18n/formats.js b/packages/kbn-i18n/src/core/formats.js similarity index 100% rename from packages/kbn-i18n/src/core/i18n/formats.js rename to packages/kbn-i18n/src/core/formats.js diff --git a/packages/kbn-i18n/src/core/i18n/helper.js b/packages/kbn-i18n/src/core/helper.js similarity index 100% rename from packages/kbn-i18n/src/core/i18n/helper.js rename to packages/kbn-i18n/src/core/helper.js diff --git a/packages/kbn-i18n/src/core/i18n/i18n.js b/packages/kbn-i18n/src/core/i18n.js similarity index 100% rename from packages/kbn-i18n/src/core/i18n/i18n.js rename to packages/kbn-i18n/src/core/i18n.js diff --git a/packages/kbn-i18n/src/core/index.js b/packages/kbn-i18n/src/core/index.js index 0eeef8faa7dde..af7c854ad979d 100644 --- a/packages/kbn-i18n/src/core/index.js +++ b/packages/kbn-i18n/src/core/index.js @@ -17,8 +17,5 @@ * under the License. */ -import * as i18nCore from './i18n'; -import * as loader from './loader'; - -export const i18n = i18nCore; -export const i18nLoader = loader; +export { formats } from './formats'; +export * from './i18n'; diff --git a/packages/kbn-i18n/src/core/i18n/locales.js b/packages/kbn-i18n/src/core/locales.js similarity index 100% rename from packages/kbn-i18n/src/core/i18n/locales.js rename to packages/kbn-i18n/src/core/locales.js diff --git a/packages/kbn-i18n/src/core/i18n/index.js b/packages/kbn-i18n/src/index.js similarity index 85% rename from packages/kbn-i18n/src/core/i18n/index.js rename to packages/kbn-i18n/src/index.js index af7c854ad979d..6988473539b82 100644 --- a/packages/kbn-i18n/src/core/i18n/index.js +++ b/packages/kbn-i18n/src/index.js @@ -17,5 +17,8 @@ * under the License. */ -export { formats } from './formats'; -export * from './i18n'; +import * as i18nCore from './core'; +import * as loader from './loader'; + +export const i18n = i18nCore; +export const i18nLoader = loader; diff --git a/packages/kbn-i18n/src/core/loader.js b/packages/kbn-i18n/src/loader.js similarity index 99% rename from packages/kbn-i18n/src/core/loader.js rename to packages/kbn-i18n/src/loader.js index a88a9e6a3674a..8718df3008e7c 100644 --- a/packages/kbn-i18n/src/core/loader.js +++ b/packages/kbn-i18n/src/loader.js @@ -29,7 +29,7 @@ import { readFile } from 'fs'; import { promisify } from 'util'; import { pick } from 'accept-language-parser'; import JSON5 from 'json5'; -import { unique } from './i18n/helper'; +import { unique } from './core/helper'; const asyncReadFile = promisify(readFile); diff --git a/packages/kbn-i18n/src/react/provider.js b/packages/kbn-i18n/src/react/provider.js index 96ed0e8b023ee..46e94863a0ba1 100644 --- a/packages/kbn-i18n/src/react/provider.js +++ b/packages/kbn-i18n/src/react/provider.js @@ -21,7 +21,7 @@ import React, { PureComponent } from 'react'; import PropTypes from 'prop-types'; import { IntlProvider } from 'react-intl'; -import * as i18n from '../core/i18n'; +import * as i18n from '../core'; /** * The library uses the provider pattern to scope an i18n context to a tree