์ข๋ ๋์๋ package.json ๋ด์ ์ฝํ
์ธ ๋ ์ ์ ๋ ๋ณต์กํด์ง๊ณ ์์ต๋๋ค. npm์ ์ด๊ธฐ์ ํ์ผ์ ํ๋ก์ ํธ/ํจํค์ง๊ฐ ์์กดํ๋ ์ข
์์ฑ์ ๋ํ ์ผ๋ถ ๋ฉํ๋ฐ์ดํฐ์ ๋ถ๊ณผํ์ต๋๋ค. ํ๋ก์ ํธ๊ฐ ์ ์ ๋ ๋ณต์กํด์ง๊ณ ์ด์ ํ
์คํธ, ํ๋ ์์ํฌ, ๊ธฐํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๊ฐ ๋ชจ๋ ํจ๊ป ์์ ์๋ ๊ฒ์ฒ๋ผ ๋ณด์ด๋ ์ข
์์ฑ์
๋๋ค. dependencies
์ devDependencies
์ ์ฝ๊ฐ์ ๊ตฌ๋ถ์ด ์์์ง๋ง ์ด๋ ๋๋ต์ ์ธ ๋ถ๋ฅ์
๋๋ค. ์ฐ๋ฆฌ๋ ์ด์ ๋ ๋ณต์กํ package.json์ ๊ธฐ์ฌํ๊ณ ๊ฑฐ์ฃผํ๋ ๋๊ตฌ๋ฅผ ๊ฐ์ง๊ณ ์์ต๋๋ค... monorepo ๊ตฌ์ฑ, lint ๊ตฌ์ฑ, ์ปค๋ฐ ๊ตฌ์ฑ, git hooks, nodemon, jest, ๋ชฉ๋ก์ ๊ณ์๋ฉ๋๋ค...
์ฃผ์์ ๋ชจ๋ ๋ณต์ก์ฑ์ ์ค๋ช ํ๋ ๋ฐฉ๋ฒ์ ์ ๊ณตํฉ๋๋ค.
๋๋ ์ฌ์ ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ์ ์ง ๊ด๋ฆฌ์๊ฐ ์ด์ ๋ฒ์ ๊ณผ์ ํธํ์ฑ์ ์ํด ์์ JSON์ ์ฌ์ฉํด์ผ ํ๋ค๊ณ ์๊ฐํ์ง๋ง, ์ต์ํ ์ด ๊ธฐ๋ฅ์ ์ ๊ณตํ๋ฉด ํ๋ก์ ํธ ์์ฑ์(๋๋ค์ ์ฌ์ฉ์)๊ฐ ์์ ์ package.json์ ๋ฌธ์ํํ ์ ์์ต๋๋ค. ๋ฌผ๋ก json์ ์ค๋ณต ํค๋ฅผ ์ฃผ์์ผ๋ก ์ฌ์ฉํ ์ ์์ง๋ง ์ด๊ฒ์ ๋๋ฌด ํดํน์ฒ๋ผ ๋๊ปด์ง๋๋ค.
์์ ๋๊ณ ์ธ์์ ์ธ ์:
{
"name": "my-project",
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "a bunch of scripts",
"ci": "a bunch of scripts",
"ci:local": "a bunch of scripts",
"docsite": "a bunch of scripts",
"docsite:combiner": "a bunch of scripts",
"docsite:sassdoc": "a bunch of scripts",
"docsite:tsdoc": "a bunch of scripts",
"e2e": "a bunch of scripts",
"html-sketchapp-install": "a bunch of scripts",
"html-sketchapp": "a bunch of scripts",
"lint": "a bunch of scripts",
"sassdoc": "a bunch of scripts",
"sassdoc:comp": "a bunch of scripts",
"sassdoc:core": "a bunch of scripts",
"start": "a bunch of scripts",
"start:hmr": "a bunch of scripts",
"start:qa": "a bunch of scripts",
"start:dev": "a bunch of scripts",
"generate-examples": "a bunch of scripts",
"rebuild-markdown": "a bunch of scripts",
"watch-examples": "a bunch of scripts",
"test:cov": "a bunch of scripts",
"test": "jest",
"test:watch": "jest --watch",
"test:cc": "jest --coverage"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"dependencies": {
"@angular-devkit/build-angular": "~0.900.1",
"@angular-devkit/build-ng-packagr": "~0.900.1",
"@angular-devkit/core": "~9.0.0",
"@angular-devkit/schematics": "~9.0.0",
"@angular/animations": "~9.0.0",
"@angular/cdk": "~9.0.0",
"@angular/cli": "~9.0.1",
"@angular/common": "~9.0.0",
"@angular/compiler": "~9.0.0",
"@angular/compiler-cli": "~9.0.0",
"@angular/core": "~9.0.0",
"@angular/forms": "~9.0.0",
"@angular/language-service": "~9.0.0",
"@angular/platform-browser": "~9.0.0",
"@angular/platform-browser-dynamic": "~9.0.0",
"@angular/router": "~9.0.0",
"@angular/service-worker": "~9.0.0",
"@angularclass/hmr": "2.1.3",
"@ngrx/effects": "~8.6.0",
"@ngrx/entity": "~8.6.0",
"@ngrx/router-store": "~8.6.0",
"@ngrx/schematics": "~8.6.0",
"@ngrx/store": "~8.6.0",
"@ngrx/store-devtools": "~8.6.0",
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/lodash-es": "^4.17.3",
"@types/node": "^12.11.1",
"classlist.js": "1.1.20150312",
"codelyzer": "^5.1.2",
"console-polyfill": "0.3.0",
"core-js": "^2.5.4",
"cz-conventional-changelog": "1.2.0",
"date-fns": "1.30.1",
"highcharts": "^7.2.1",
"highcharts-angular": "^2.4.0",
"html2canvas": "^1.0.0-rc.5",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
"lodash-es": "^4.17.11",
"mime": "~2.4.2",
"ngrx-store-freeze": "0.2.4",
"ngx-monaco-editor": "~8.0.0",
"ngx-quill": "^7.3.12",
"pdfmake": "^0.1.64",
"prettier": "1.19.1",
"protractor": "~5.4.3",
"quill": "^1.3.7",
"rxjs": "~6.5.4",
"rxjs-compat": "^6.0.0",
"standard-changelog": "1.0.19",
"svgxuse": "1.2.6",
"ts-node": "~8.3.0",
"tsickle": "^0.35.0",
"tslib": "^1.10.0",
"tslint": "~5.18.0",
"typescript": "~3.7.5",
"web-animations-js": "~2.3.1",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@types/jest": "^24.0.6",
"jest": "^24.1.0",
"jest-preset-angular": "^6.0.2",
"ts-node": "~7.0.1",
"typescript": "3.2.4"
},
"jest": {
"preset": "jest-preset-angular",
"setupTestFrameworkScriptFile": "<rootDir>/setupJest.ts"
},
"nodemonConfig": {
"ignore": [
"**/example-module.ts"
],
"watch": [
"./a/bunch/of/stuff"
],
"ext": "js ts md html"
},
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**"
]
}
}
์ฃผ์์ด ์๋ package.json์ ์.
{
"name": "my-project",
"version": "0.0.1",
"license": "MIT",
"scripts": {
"build": "a bunch of scripts",
"ci": "a bunch of scripts",
"ci:local": "a bunch of scripts",
// for building our documentation site
"docsite": "a bunch of scripts",
"docsite:combiner": "a bunch of scripts",
"docsite:sassdoc": "a bunch of scripts",
"docsite:tsdoc": "a bunch of scripts",
"e2e": "a bunch of scripts",
"lint": "a bunch of scripts",
"sassdoc": "a bunch of scripts",
"sassdoc:comp": "a bunch of scripts",
"sassdoc:core": "a bunch of scripts",
"start": "a bunch of scripts",
"start:hmr": "a bunch of scripts",
"start:qa": "a bunch of scripts",
"start:dev": "a bunch of scripts",
"generate-examples": "a bunch of scripts",
"rebuild-markdown": "a bunch of scripts",
"watch-examples": "a bunch of scripts",
"test:cov": "a bunch of scripts",
"test": "jest",
"test:watch": "jest --watch",
"test:cc": "jest --coverage"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"dependencies": {
// ANGULAR
"@angular-devkit/build-angular": "~0.900.1",
"@angular-devkit/build-ng-packagr": "~0.900.1",
"@angular-devkit/core": "~9.0.0",
"@angular-devkit/schematics": "~9.0.0",
"@angular/animations": "~9.0.0",
"@angular/cdk": "~9.0.0",
"@angular/cli": "~9.0.1",
"@angular/common": "~9.0.0",
"@angular/compiler": "~9.0.0",
"@angular/compiler-cli": "~9.0.0",
"@angular/core": "~9.0.0",
"@angular/forms": "~9.0.0",
"@angular/language-service": "~9.0.0",
"@angular/platform-browser": "~9.0.0",
"@angular/platform-browser-dynamic": "~9.0.0",
"@angular/router": "~9.0.0",
"@angular/service-worker": "~9.0.0",
"@angularclass/hmr": "2.1.3",
"zone.js": "~0.10.2",
"rxjs": "~6.5.4",
"rxjs-compat": "^6.0.0",
// polyfills for angular
"console-polyfill": "0.3.0",
"core-js": "^2.5.4",
"classlist.js": "1.1.20150312",
"svgxuse": "1.2.6",
"web-animations-js": "~2.3.1",
// lint management
"codelyzer": "^5.1.2",
"prettier": "1.19.1",
"tslint": "~5.18.0",
// changelog creation
"cz-conventional-changelog": "1.2.0",
"standard-changelog": "1.0.19",
// ngrx state management
"@ngrx/effects": "~8.6.0",
"@ngrx/entity": "~8.6.0",
"@ngrx/router-store": "~8.6.0",
"@ngrx/schematics": "~8.6.0",
"@ngrx/store": "~8.6.0",
"@ngrx/store-devtools": "~8.6.0",
"ngrx-store-freeze": "0.2.4",
// library deps
// Graphs support
"highcharts": "^7.2.1",
"highcharts-angular": "^2.4.0",
// for creating pdfs
"html2canvas": "^1.0.0-rc.5",
"pdfmake": "^0.1.64",
// rich text support
"ngx-quill": "^7.3.12",
"quill": "^1.3.7",
// testing
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.2",
// e2e testing
"protractor": "~5.4.3",
// typscript and compilation
"ts-node": "~8.3.0",
"tsickle": "^0.35.0",
"tslib": "^1.10.0",
"typescript": "~3.7.5",
// misc deps
"date-fns": "1.30.1",
"lodash-es": "^4.17.11",
"mime": "~2.4.2"
},
"devDependencies": {
"@types/jasmine": "~3.5.0",
"@types/jasminewd2": "~2.0.3",
"@types/lodash-es": "^4.17.3",
"@types/node": "^12.11.1",
"@types/jest": "^24.0.6",
"jest": "^24.1.0",
"jest-preset-angular": "^6.0.2",
"ts-node": "~7.0.1",
"typescript": "3.2.4"
},
// complicated jest configuration here
"jest": {
"preset": "jest-preset-angular",
"setupTestFrameworkScriptFile": "<rootDir>/setupJest.ts"
},
// use nodemon to trigger stuff
"nodemonConfig": {
"ignore": [
"**/example-module.ts"
],
"watch": [
"./a/bunch/of/stuff"
],
"ext": "js ts md html"
},
// extra libraries we are creating internally
"workspaces": {
"packages": [
"packages/*"
],
"nohoist": [
"**"
]
}
}
https://github.com/microsoft/node-jsonc-parser
Typescript๋ tsconfig.json ํ์ผ์์ ์ฃผ์์ ์ฌ์ฉํฉ๋๋ค.
@admosity ๋ถํํ๋ ์ด๊ฒ์ ์ด์ ๋ฒ์ ๊ณผ ํธํ๋์ง ์์ต๋๋ค. ๋ํ ์๋ก์ด ๊ตฌ๋ฌธ์ ์ดํดํ๋ ค๋ฉด package.json๊ณผ ๋ง์ npm ํจํค์ง๋ฅผ ์ฌ์ฉํ๋ ๋ค๋ฅธ ๋ชจ๋ ์ํํธ์จ์ด๊ฐ ํ์ํฉ๋๋ค...
์ด๊ฒ์ ์ด์ ๋ฒ์ ๊ณผ ํธํ๋์ง ์์ต๋๋ค.
์ด์ ๋ฒ์ ๊ณผ์ ํธํ์ฑ์ ์ ์งํ๊ธฐ ์ํด ๋ ๊ฐ์ ํ์ผ์ด ์์ ์ ์์ต๋๋ค.
ํจํค์ง.json
ํจํค์ง.json5
์ฌ์ฉ์๋ package.json5๋ฅผ ํธ์งํ์ฌ ์ฃผ์์ ์ถ๊ฐํ๊ธฐ๋ง ํ๋ฉด ๋ฉ๋๋ค. Npm์ package.json์ ์์ฑ(๋๋ ์ฌ์ ์)ํ๊ณ package.json5์ ์ฃผ์์ ๋ฌด์ํ ์ ์์ต๋๋ค.
์๋ก์ด ๊ธฐ๋ฅ์ ์ ์์ ์ด์ ๋ฒ์ ๊ณผ ํธํ๋์ง ์์ต๋๋ค. ์ด๋ ์ ์์ ์ธ ํ์์ด ์๋๋ฉฐ ์ํํธ์จ์ด์ ์งํ๊ฐ ์งํ๋๋ ํน์ฑ์ ์์ง ์์ต๋๊น?
package.json
๋ฅผ ๋ก๋ํ๋ ๋ค๋ฅธ ํ๋ก์ ํธ์์ ํจํค์ง๋ฅผ ์ถ๊ฐํ๊ณ JSON
๋ฅผ JSON5
๋ฐ๊พธ๋ ๊ฒ๋ง์ผ๋ก ๋งค์ฐ ์ฝ๊ฒ ์์ ๋๋ ๊ฒ ์ธ์๋ API๋ ๋์ผํฉ๋๋ค.
Babel์ ์ผ๋ง ์ ์ JSON5 ์ง์์ ์ถ๊ฐํ๊ณ ์ปค๋ฎค๋ํฐ๋ ์์ผ๋ก ๋์๊ฐ ์๊ฐ์ด ์ ํ ๊ฑธ๋ฆฌ์ง ์๋ ์ด๋ฌํ ์์ ๋ฌธ์ ๋ฅผ ์์ ํฉ๋๋ค. JSON5์ ๊ฐ์ ์ฌํญ์ ๋ค๋ฅธ ํจํค์ง๋ก ์ ๊ธฐ์ ์ผ๋ก ํ์ฐ๋๊ณ ๋ฌธ์ ๊ฐ์ ์ฌํญ์ ํ๋ก์ ํธ๋ก ํ์ฐ๋ฉ๋๋ค.
์ข์ ์ผ์ธ ๊ฒ ๊ฐ์ต๋๋ค.
IMO, ์์ผ๋ก ๋์๊ฐ์ง ์๋ ๊ฒ์ ๋ํ ๋ณ๋ช ์ ์ ๊ณตํ๊ธฐ ์ํด ๋ ๋ง์ ๋ณต์ก์ฑ/ํผ๋์ ์ถ๊ฐํ์ง ๋ง์ญ์์ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
์๋ก์ด ๊ธฐ๋ฅ์ ์ ์์ ์ด์ ๋ฒ์ ๊ณผ ํธํ๋์ง ์์ต๋๋ค. ์ด๋ ์ ์์ ์ธ ํ์์ด ์๋๋ฉฐ ์ํํธ์จ์ด์ ์งํ๊ฐ ์งํ๋๋ ํน์ฑ์ ์์ง ์์ต๋๊น?
package.json
๋ฅผ ๋ก๋ํ๋ ๋ค๋ฅธ ํ๋ก์ ํธ์์ ํจํค์ง๋ฅผ ์ถ๊ฐํ๊ณJSON
๋ฅผJSON5
๋ฐ๊พธ๋ ๊ฒ๋ง์ผ๋ก ๋งค์ฐ ์ฝ๊ฒ ์์ ๋๋ ๊ฒ ์ธ์๋ API๋ ๋์ผํฉ๋๋ค.Babel์ ์ผ๋ง ์ ์ JSON5 ์ง์์ ์ถ๊ฐํ๊ณ ์ปค๋ฎค๋ํฐ๋ ์์ผ๋ก ๋์๊ฐ ์๊ฐ์ด ์ ํ ๊ฑธ๋ฆฌ์ง ์๋ ์ด๋ฌํ ์์ ๋ฌธ์ ๋ฅผ ์์ ํฉ๋๋ค. JSON5์ ๊ฐ์ ์ฌํญ์ ๋ค๋ฅธ ํจํค์ง๋ก ์ ๊ธฐ์ ์ผ๋ก ํ์ฐ๋๊ณ ๋ฌธ์ ๊ฐ์ ์ฌํญ์ ํ๋ก์ ํธ๋ก ํ์ฐ๋ฉ๋๋ค.
์ข์ ์ผ์ธ ๊ฒ ๊ฐ์ต๋๋ค.
IMO, ์์ผ๋ก ๋์๊ฐ์ง ์๋ ๊ฒ์ ๋ํ ๋ณ๋ช ์ ์ ๊ณตํ๊ธฐ ์ํด ๋ ๋ง์ ๋ณต์ก์ฑ/ํผ๋์ ์ถ๊ฐํ์ง ๋ง์ญ์์ค.