Skip to content

Instantly share code, notes, and snippets.

@atomicpages
Last active November 26, 2019 01:55
Show Gist options
  • Save atomicpages/f6d534f6e1ed74146758de70ecde9cb3 to your computer and use it in GitHub Desktop.
Save atomicpages/f6d534f6e1ed74146758de70ecde9cb3 to your computer and use it in GitHub Desktop.
Minimum verifiable example of JSON import using pika
import locales from './translation.json';
console.log(locales.en['Hello, {{name}}'].replace('{{name}}', 'Dennis'));
{
"name": "json-import-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"clean": "shx rm -rf pkg/",
"build": "npm run clean && pika build"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@pika/pack": "^0.5.0",
"@pika/plugin-build-node": "^0.8.1",
"@pika/plugin-build-web": "^0.8.1",
"@pika/plugin-copy-assets": "^0.8.1",
"@pika/plugin-ts-standard-pkg": "^0.8.1",
"prettier": "^1.19.1",
"shx": "^0.3.2",
"typescript": "^3.7.2"
},
"@pika/pack": {
"pipeline": [
[
"@pika/plugin-ts-standard-pkg"
],
[
"@pika/plugin-build-node"
],
[
"@pika/plugin-build-web"
]
]
},
"prettier": {
"tabWidth": 4,
"singleQuote": true,
"trailingComma": "es5"
}
}
{
"en": {
"Hello, {{name}}": "Hello, {{name}}"
},
"es": {
"Hola, {{name}}": "Hola, {{name}}"
},
"fr": {
"Bonjur, {{name}}": "Bonjur, {{name}}"
}
}
{
"compilerOptions": {
"esModuleInterop": true,
"downlevelIteration": true,
"lib": ["es2015"],
"moduleResolution": "node",
"resolveJsonModule": true,
"module": "ESNext",
"target": "es2019"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment