Skip to content

Commit 94f47e5

Browse files
committed
- add .npmignore
- fix useI18next Signed-off-by: Dmitriy Nevzorov <[email protected]>
1 parent 8ef1ba0 commit 94f47e5

11 files changed

+518
-390
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
["babel-preset-gatsby-package", { "browser": true }]
4+
]
5+
}

.npmignore

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Logs
2+
logs
3+
*.log
4+
5+
# Runtime data
6+
pids
7+
*.pid
8+
*.seed
9+
10+
# Directory for instrumented libs generated by jscoverage/JSCover
11+
lib-cov
12+
13+
# Coverage directory used by tools like istanbul
14+
coverage
15+
16+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17+
.grunt
18+
19+
# node-waf configuration
20+
.lock-wscript
21+
22+
# Compiled binary addons (http://nodejs.org/api/addons.html)
23+
build/Release
24+
25+
# Dependency directory
26+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27+
node_modules
28+
*.un~
29+
yarn.lock
30+
src
31+
flow-typed
32+
coverage
33+
decls
34+
example

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ module.exports = {
275275
```json
276276
{
277277
"scripts": {
278-
"extract": "yarn run babel -f babel.config.js -o tmp/chunk.js 'src/**/*.{js,jsx,ts,tsx}' && rm -rf tmp"
278+
"extract": "yarn run babel -f babel-extract.config.js -o tmp/chunk.js 'src/**/*.{js,jsx,ts,tsx}' && rm -rf tmp"
279279
}
280280
}
281281
```
File renamed without changes.

example/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"serve": "gatsby serve",
3939
"clean": "gatsby clean",
4040
"test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1",
41-
"extract": "yarn run babel -f babel.config.js -o tmp/chunk.js 'src/**/*.{js,jsx,ts,tsx}' && rm -rf tmp",
41+
"extract": "yarn run babel -f babel-extract.config.js -o tmp/chunk.js 'src/**/*.{js,jsx,ts,tsx}' && rm -rf tmp",
4242
"translate": "yarn run extract && node translate.js"
4343
},
4444
"repository": {

example/yarn.lock

+390-372
Large diffs are not rendered by default.

gatsby-ssr.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
module.exports = require('./dist/gatsby-ssr');
1+
const ssr = require('./dist/gatsby-ssr');
2+
console.log(ssr);
3+
4+
module.exports = ssr;

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@
2828
"gatsby-ssr.js"
2929
],
3030
"scripts": {
31-
"build": "tsc --declaration --outDir dist",
32-
"dev": "tsc --watch --declaration --outDir dist",
33-
"prepare": "yarn run build",
31+
"build:ts": "babel src --out-dir dist --extensions '.ts,.tsx'",
32+
"build:defs": "tsc --declaration --outDir dist --emitDeclarationOnly",
33+
"prepare": "NODE_ENV=production yarn run build:ts && yarn run build:defs",
34+
"dev": "babel -w src --out-dir dist --extensions '.ts,.tsx'",
3435
"release": "release-it"
3536
},
3637
"devDependencies": {
38+
"@babel/cli": "^7.8.4",
3739
"@types/bluebird": "^3.5.32",
3840
"@types/react": "^16.9.35",
41+
"babel-preset-gatsby-package": "^0.4.2",
3942
"gatsby": "^2.22.9",
4043
"husky": "^4.2.5",
4144
"prettier": "^2.0.5",

src/lib/useI18next.ts

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export const useI18next = (ns?: Namespace, options?: UseTranslationOptions) => {
1212
const {i18n, t, ready} = useTranslation(ns, options);
1313
const context = useContext(I18nextContext);
1414

15-
if (typeof window === 'undefined') return;
1615
const {routed, defaultLanguage} = context;
1716

1817
const getUrlLanguage = (language: string) => {

tsconfig.json

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"compilerOptions": {
33
"target": "es5",
4-
"lib": [
5-
"dom",
6-
"dom.iterable",
7-
"esnext"
8-
],
4+
"lib": ["dom", "dom.iterable", "esnext"],
95
"allowJs": true,
106
"skipLibCheck": true,
117
"esModuleInterop": true,
@@ -15,10 +11,9 @@
1511
"module": "commonjs",
1612
"moduleResolution": "node",
1713
"resolveJsonModule": true,
14+
"sourceMap": true,
1815
"isolatedModules": true,
1916
"jsx": "react"
2017
},
21-
"include": [
22-
"src"
23-
]
18+
"include": ["src"]
2419
}

yarn.lock

+74-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22
# yarn lockfile v1
33

44

5+
"@babel/cli@^7.8.4":
6+
version "7.8.4"
7+
resolved "https://registry.yarnpkg.com/@babel/cli/-/cli-7.8.4.tgz#505fb053721a98777b2b175323ea4f090b7d3c1c"
8+
integrity sha512-XXLgAm6LBbaNxaGhMAznXXaxtCWfuv6PIDJ9Alsy9JYTOh+j2jJz+L/162kkfU1j/pTSxK1xGmlwI4pdIMkoag==
9+
dependencies:
10+
commander "^4.0.1"
11+
convert-source-map "^1.1.0"
12+
fs-readdir-recursive "^1.1.0"
13+
glob "^7.0.0"
14+
lodash "^4.17.13"
15+
make-dir "^2.1.0"
16+
slash "^2.0.0"
17+
source-map "^0.5.0"
18+
optionalDependencies:
19+
chokidar "^2.1.8"
20+
521
"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.8.3":
622
version "7.8.3"
723
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.8.3.tgz#33e25903d7481181534e12ec0a25f16b6fcf419e"
@@ -370,6 +386,13 @@
370386
dependencies:
371387
"@babel/helper-plugin-utils" "^7.8.0"
372388

389+
"@babel/plugin-syntax-flow@^7.8.3":
390+
version "7.8.3"
391+
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.8.3.tgz#f2c883bd61a6316f2c89380ae5122f923ba4527f"
392+
integrity sha512-innAx3bUbA0KSYj2E2MNFSn9hiCeowOFLxlsuhXzw8hMQnzkDomUr9QCD7E9VF60NmnG1sNTuuv6Qf4f8INYsg==
393+
dependencies:
394+
"@babel/helper-plugin-utils" "^7.8.3"
395+
373396
"@babel/plugin-syntax-json-strings@^7.8.0":
374397
version "7.8.3"
375398
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz#01ca21b668cd8218c9e640cb6dd88c5412b2c96a"
@@ -515,6 +538,14 @@
515538
"@babel/helper-builder-binary-assignment-operator-visitor" "^7.8.3"
516539
"@babel/helper-plugin-utils" "^7.8.3"
517540

541+
"@babel/plugin-transform-flow-strip-types@^7.9.0":
542+
version "7.9.0"
543+
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.9.0.tgz#8a3538aa40434e000b8f44a3c5c9ac7229bd2392"
544+
integrity sha512-7Qfg0lKQhEHs93FChxVLAvhBshOPQDtJUTVHr/ZwQNRccCm4O9D79r9tVSoV8iNwjP1YgfD+e/fgHcPkN1qEQg==
545+
dependencies:
546+
"@babel/helper-plugin-utils" "^7.8.3"
547+
"@babel/plugin-syntax-flow" "^7.8.3"
548+
518549
"@babel/plugin-transform-for-of@^7.9.0":
519550
version "7.9.0"
520551
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.9.0.tgz#0f260e27d3e29cd1bb3128da5e76c761aa6c108e"
@@ -721,7 +752,7 @@
721752
dependencies:
722753
"@babel/helper-plugin-utils" "^7.8.3"
723754

724-
"@babel/plugin-transform-typescript@^7.9.0":
755+
"@babel/plugin-transform-typescript@^7.9.0", "@babel/plugin-transform-typescript@^7.9.6":
725756
version "7.9.6"
726757
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.9.6.tgz#2248971416a506fc78278fc0c0ea3179224af1e9"
727758
integrity sha512-8OvsRdvpt3Iesf2qsAn+YdlwAJD7zJ+vhFZmDCa4b8dTp7MmHtKk5FF2mCsGxjZwuwsy/yIIay/nLmxST1ctVQ==
@@ -812,6 +843,14 @@
812843
levenary "^1.1.1"
813844
semver "^5.5.0"
814845

846+
"@babel/preset-flow@^7.9.0":
847+
version "7.9.0"
848+
resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.9.0.tgz#fee847c3e090b0b2d9227c1949e4da1d1379280d"
849+
integrity sha512-88uSmlshIrlmPkNkEcx3UpSZ6b8n0UGBq0/0ZMZCF/uxAW0XIAUuDHBhIOAh0pvweafH4RxOwi/H3rWhtqOYPA==
850+
dependencies:
851+
"@babel/helper-plugin-utils" "^7.8.3"
852+
"@babel/plugin-transform-flow-strip-types" "^7.9.0"
853+
815854
"@babel/preset-modules@^0.1.3":
816855
version "0.1.3"
817856
resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.3.tgz#13242b53b5ef8c883c3cf7dddd55b36ce80fbc72"
@@ -2088,6 +2127,23 @@ babel-plugin-transform-react-remove-prop-types@^0.4.24:
20882127
resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-remove-prop-types/-/babel-plugin-transform-react-remove-prop-types-0.4.24.tgz#f2edaf9b4c6a5fbe5c1d678bfb531078c1555f3a"
20892128
integrity sha512-eqj0hVcJUR57/Ug2zE1Yswsw4LhuqqHhD+8v120T1cl3kjg76QwtyBrdIk4WVwK+lAhBJVYCd/v+4nc4y+8JsA==
20902129

2130+
babel-preset-gatsby-package@^0.4.2:
2131+
version "0.4.2"
2132+
resolved "https://registry.yarnpkg.com/babel-preset-gatsby-package/-/babel-preset-gatsby-package-0.4.2.tgz#132646b4fb401dd4ea915076a635b9e27feadbd6"
2133+
integrity sha512-OF0dtcvsfSSZFJt1fcrW7vt3kreS6USmtEKOJ4f5V/I7XDTdACnq1BT82spoUDOMjZq6lWlWuXUkHt9sp1Ws3g==
2134+
dependencies:
2135+
"@babel/plugin-proposal-class-properties" "^7.8.3"
2136+
"@babel/plugin-proposal-nullish-coalescing-operator" "^7.8.3"
2137+
"@babel/plugin-proposal-optional-chaining" "^7.9.0"
2138+
"@babel/plugin-syntax-dynamic-import" "^7.8.3"
2139+
"@babel/plugin-transform-runtime" "^7.9.6"
2140+
"@babel/plugin-transform-typescript" "^7.9.6"
2141+
"@babel/preset-env" "^7.9.6"
2142+
"@babel/preset-flow" "^7.9.0"
2143+
"@babel/preset-react" "^7.9.4"
2144+
babel-plugin-dynamic-import-node "^2.3.3"
2145+
core-js "^2.6.11"
2146+
20912147
babel-preset-gatsby@^0.4.7:
20922148
version "0.4.7"
20932149
resolved "https://registry.yarnpkg.com/babel-preset-gatsby/-/babel-preset-gatsby-0.4.7.tgz#a23945eea34817d09988b434b2fe4c46f69b3ad6"
@@ -2971,6 +3027,11 @@ commander@^2.11.0, commander@^2.20.0:
29713027
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
29723028
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
29733029

3030+
commander@^4.0.1:
3031+
version "4.1.1"
3032+
resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068"
3033+
integrity sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==
3034+
29743035
common-tags@^1.8.0:
29753036
version "1.8.0"
29763037
resolved "https://registry.yarnpkg.com/common-tags/-/common-tags-1.8.0.tgz#8e3153e542d4a39e9b10554434afaaf98956a937"
@@ -3119,7 +3180,7 @@ convert-hrtime@^3.0.0:
31193180
resolved "https://registry.yarnpkg.com/convert-hrtime/-/convert-hrtime-3.0.0.tgz#62c7593f5809ca10be8da858a6d2f702bcda00aa"
31203181
integrity sha512-7V+KqSvMiHp8yWDuwfww06XleMWVVB9b9tURBx+G7UTADuo5hYPuowKloz4OzOqbPezxgo+fdQ1522WzPG4OeA==
31213182

3122-
convert-source-map@^1.7.0:
3183+
convert-source-map@^1.1.0, convert-source-map@^1.7.0:
31233184
version "1.7.0"
31243185
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442"
31253186
integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==
@@ -4911,6 +4972,11 @@ fs-extra@^8.1.0:
49114972
jsonfile "^4.0.0"
49124973
universalify "^0.1.0"
49134974

4975+
fs-readdir-recursive@^1.1.0:
4976+
version "1.1.0"
4977+
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27"
4978+
integrity sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==
4979+
49144980
fs-write-stream-atomic@^1.0.8:
49154981
version "1.0.10"
49164982
resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9"
@@ -7343,7 +7409,7 @@ make-dir@^1.0.0:
73437409
dependencies:
73447410
pify "^3.0.0"
73457411

7346-
make-dir@^2.0.0:
7412+
make-dir@^2.0.0, make-dir@^2.1.0:
73477413
version "2.1.0"
73487414
resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5"
73497415
integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==
@@ -10198,6 +10264,11 @@ sisteransi@^1.0.4:
1019810264
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
1019910265
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==
1020010266

10267+
slash@^2.0.0:
10268+
version "2.0.0"
10269+
resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
10270+
integrity sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==
10271+
1020110272
slash@^3.0.0:
1020210273
version "3.0.0"
1020310274
resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634"

0 commit comments

Comments
 (0)