From f2f918587d5bdb9ad601e021e0ed3122ce02cb14 Mon Sep 17 00:00:00 2001 From: WoodNeck Date: Wed, 28 Oct 2020 19:13:26 +0900 Subject: [PATCH] chore: configure build script --- .eslintrc | 26 ------ package-lock.json | 124 +++++++++++++++++++++++++++-- package.json | 9 ++- rollup.config.js | 154 ++++++++++++++++++++++++++++-------- src/PanoViewer/index.umd.ts | 7 ++ src/SpinViewer/index.umd.ts | 9 +++ src/index.ts | 2 +- src/index.umd.ts | 10 +++ 8 files changed, 273 insertions(+), 68 deletions(-) delete mode 100644 .eslintrc create mode 100644 src/PanoViewer/index.umd.ts create mode 100644 src/SpinViewer/index.umd.ts create mode 100644 src/index.umd.ts diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index d0efa9bc6..000000000 --- a/.eslintrc +++ /dev/null @@ -1,26 +0,0 @@ -{ - // Airbnb en https://github.com/airbnb/javascript - // Airbnb ko https://github.com/tipjs/javascript-style-guide - // Naver https://oss.navercorp.com/engineering/coding-convention - // Naver http://docs.navercorp.com/coding-convention/js.html - "extends": "naver", - "parser": "babel-eslint", - "rules": { - "comma-dangle": "off", - "import/prefer-default-export": "off", - "linebreak-style": 0, - "array-element-newline": "off", - "class-methods-use-this": "off", - "no-unused-expressions": 0, - "newline-per-chained-call": "off" - }, - "plugins": [ - "chai-friendly" - ], - "env": { - "mocha": true - }, - "globals": { - "Simulator": false - } -} diff --git a/package-lock.json b/package-lock.json index 5f6f86327..7a469aee1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -955,6 +955,59 @@ } } }, + "@egjs/build-helper": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@egjs/build-helper/-/build-helper-0.1.2.tgz", + "integrity": "sha512-VdTllKles30qLgutKwIxapwXGEuU5kS95b+u01unphw3TouGROskPvLqEJ7SIubqgPc6q3vRlTgOe75yhaYF8w==", + "dev": true, + "requires": { + "rollup": "^1.7.4", + "rollup-plugin-commonjs": "^9.3.4", + "rollup-plugin-node-resolve": "^4.0.1", + "rollup-plugin-prototype-minify": "^1.0.5", + "rollup-plugin-replace": "^2.1.1", + "rollup-plugin-typescript": "^1.0.1", + "rollup-plugin-uglify": "^6.0.2", + "rollup-plugin-visualizer": "^1.1.0" + }, + "dependencies": { + "acorn": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", + "dev": true + }, + "builtin-modules": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz", + "integrity": "sha512-k0KL0aWZuBt2lrxrcASWDfwOLMnodeQjodT/1SxEQAXsHANgo6ZC/VEaSEHCXt7aSTZ4/4H5LKa+tBXmW7Vtvw==", + "dev": true + }, + "rollup": { + "version": "1.32.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", + "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", + "dev": true, + "requires": { + "@types/estree": "*", + "@types/node": "*", + "acorn": "^7.1.0" + } + }, + "rollup-plugin-node-resolve": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-4.2.4.tgz", + "integrity": "sha512-t/64I6l7fZ9BxqD3XlX4ZeO6+5RLKyfpwE2CiPNUKa+GocPlQhf/C208ou8y3AwtNsc6bjSk/8/6y/YAyxCIvw==", + "dev": true, + "requires": { + "@types/resolve": "0.0.8", + "builtin-modules": "^3.1.0", + "is-module": "^1.0.0", + "resolve": "^1.10.0" + } + } + } + }, "@egjs/common-demo": { "version": "github:naver/egjs#2e8a4a33a0a2f44bcb04974cfb96a1fc6e87c30a", "from": "github:naver/egjs#common-demo", @@ -1066,6 +1119,15 @@ "integrity": "sha512-8sRGhbpU+ck1n0PGAUgVrWrWdjSW2aqNeyC15W88GRsMpSwzv6RJGlLhE7s2RhVSOdyDmxbqlWSeThq4/7xqlA==", "dev": true }, + "@types/resolve": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz", + "integrity": "sha512-auApPaJf3NPfe18hSoJkp8EbZzer2ISk7o8mCC3M9he/a04+gbMF97NkpD2S8riMGvm4BMRI59/SZQSaLTKpsQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/webxr": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/@types/webxr/-/webxr-0.1.0.tgz", @@ -8176,11 +8238,6 @@ "integrity": "sha512-bV7f+6l2QigeBBZSM/6yTNq4P2fNpSWj/0e7jQcy87A8e7o2nAfP/34/2ky5Vw4B9S446EtIhodAzkFCcR4dQg==", "dev": true }, - "motion-sensors-polyfill": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/motion-sensors-polyfill/-/motion-sensors-polyfill-0.3.1.tgz", - "integrity": "sha1-+N/hhhS3GcddjEZpFKOTG/yMjR8=" - }, "move-concurrently": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz", @@ -9184,6 +9241,18 @@ "integrity": "sha1-mEcocL8igTL8vdhoEputEsPAKeM=", "dev": true }, + "prototype-minify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/prototype-minify/-/prototype-minify-1.1.0.tgz", + "integrity": "sha512-xsxG/Bh06Y0keIM/DNsOnX0lFuPVrhl7v48FxEHg8xCAjPjjoI2EruVdJbzfYHCGqf8HqD4JI3s7gsWZ392x9w==", + "dev": true, + "requires": { + "@babel/generator": "^7.1.2", + "@babel/parser": "^7.1.2", + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.1.2" + } + }, "proxy-addr": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", @@ -9817,6 +9886,15 @@ "resolve": "^1.1.6" } }, + "rollup-plugin-prototype-minify": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/rollup-plugin-prototype-minify/-/rollup-plugin-prototype-minify-1.1.0.tgz", + "integrity": "sha512-8kMi+F3Zy1q3NnxJbfIQuH0trYA1GxAtJjGxNidupsLIi47/azAM1rFvIlyeAD3gkqL3ZP/YrQgevH07D17b6g==", + "dev": true, + "requires": { + "prototype-minify": "^1.1.0" + } + }, "rollup-plugin-replace": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/rollup-plugin-replace/-/rollup-plugin-replace-2.2.0.tgz", @@ -9827,6 +9905,16 @@ "rollup-pluginutils": "^2.6.0" } }, + "rollup-plugin-typescript": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-typescript/-/rollup-plugin-typescript-1.0.1.tgz", + "integrity": "sha512-rwJDNn9jv/NsKZuyBb/h0jsclP4CJ58qbvZt2Q9zDIGILF2LtdtvCqMOL+Gq9IVq5MTrTlHZNrn8h7VjQgd8tw==", + "dev": true, + "requires": { + "resolve": "^1.10.0", + "rollup-pluginutils": "^2.5.0" + } + }, "rollup-plugin-uglify": { "version": "6.0.4", "resolved": "https://registry.npmjs.org/rollup-plugin-uglify/-/rollup-plugin-uglify-6.0.4.tgz", @@ -9839,6 +9927,26 @@ "uglify-js": "^3.4.9" } }, + "rollup-plugin-visualizer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/rollup-plugin-visualizer/-/rollup-plugin-visualizer-1.1.1.tgz", + "integrity": "sha512-7xkSKp+dyJmSC7jg2LXqViaHuOnF1VvIFCnsZEKjrgT5ZVyiLLSbeszxFcQSfNJILphqgAEmWAUz0Z4xYScrRw==", + "dev": true, + "requires": { + "mkdirp": "^0.5.1", + "opn": "^5.4.0", + "source-map": "^0.7.3", + "typeface-oswald": "0.0.54" + }, + "dependencies": { + "source-map": { + "version": "0.7.3", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.3.tgz", + "integrity": "sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ==", + "dev": true + } + } + }, "rollup-pluginutils": { "version": "2.8.2", "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", @@ -11456,6 +11564,12 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typeface-oswald": { + "version": "0.0.54", + "resolved": "https://registry.npmjs.org/typeface-oswald/-/typeface-oswald-0.0.54.tgz", + "integrity": "sha512-U1WMNp4qfy4/3khIfHMVAIKnNu941MXUfs3+H9R8PFgnoz42Hh9pboSFztWr86zut0eXC8byalmVhfkiKON/8Q==", + "dev": true + }, "typescript": { "version": "3.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.9.3.tgz", diff --git a/package.json b/package.json index 72f5a57dc..a0cba16a9 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,6 @@ "types": "declaration/index.d.ts", "scripts": { "start": "webpack-dev-server --open --host 0.0.0.0", - "build:webpack": "webpack --env.mode=production && webpack --env.mode=packaged", "build": "rm -rf ./dist && rollup -c && npm run printsizes", "printsizes": "print-sizes ./dist --exclude=\\.map", "test": "karma start", @@ -29,6 +28,10 @@ "prepush": "npm run lint", "commitmsg": "node config/validate-commit-msg.js", "changelog": "node config/changelog.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/naver/egjs-view360" }, "author": { "name": "NAVER Corp." @@ -44,9 +47,9 @@ "dependencies": { "@egjs/agent": "^2.2.1", "@egjs/axes": "^2.7.1", + "@egjs/component": "^2.2.2", "es6-promise": "^4.2.5", "gl-matrix": "^3.3.0", - "motion-sensors-polyfill": "^0.3.1", "webvr-polyfill": "^0.9.41" }, "devDependencies": { @@ -56,8 +59,8 @@ "@babel/plugin-transform-modules-commonjs": "^7.1.0", "@babel/preset-env": "^7.0.0", "@daybrush/jsdoc": "^0.3.8", + "@egjs/build-helper": "^0.1.2", "@egjs/common-demo": "github:naver/egjs#common-demo", - "@egjs/component": "^2.2.2", "@egjs/visible": "^2.1.0", "@types/webxr": "^0.1.0", "babel-eslint": "^10.0.1", diff --git a/rollup.config.js b/rollup.config.js index 078feaf5e..6fa142749 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,36 +1,124 @@ -const babel = require("rollup-plugin-babel"); -const replace = require("rollup-plugin-replace"); -const json = require("rollup-plugin-json"); -const version = process.env.NIGHTLY || require("./package.json").version; -const merge = require("./rollup/merge").mergeList; -const banner = require("./rollup/banner").banner; +const buildHelper = require("@egjs/build-helper"); -const replaceVersion = replace({ - "#__VERSION__#": version, - delimiters: ["", ""] -}); +const external = { + "@egjs/axes": "eg.Axes", + "@egjs/component": "eg.Component", + "@egjs/agent": "eg.agent", + "gl-matrix": "glMatrix", + "webvr-polyfill": "WebVRPolyfill", +} +const name = "eg.view360"; -const defaultConfig = { - plugins: [ - babel({ - include: ["src/**"], - configFile: "./babel.config.js" - }), - replaceVersion, - json(), - ], - output: { - name: "eg.view360", - banner, - freeze: false, - format: "umd", - interop: false, - sourcemap: true - } -}; - -export default merge(defaultConfig, [ - ...require("./rollup/rollup.config.esm"), - ...require("./rollup/rollup.config.development"), - ...require("./rollup/rollup.config.pkgd") +export default buildHelper([ + { + name, + input: "./src/index.umd.ts", + output: "./dist/view360.js", + format: "umd", + commonjs: true, + external, + }, + { + name, + input: "./src/PanoViewer/index.umd.ts", + output: "./dist/view360.panoviewer.js", + format: "umd", + commonjs: true, + external, + }, + { + name, + input: "./src/SpinViewer/index.umd.ts", + output: "./dist/view360.spinviewer.js", + format: "umd", + commonjs: true, + external, + }, + { + name, + input: "./src/index.umd.ts", + output: "./dist/view360.min.js", + format: "umd", + commonjs: true, + uglify: true, + external, + }, + { + name, + input: "./src/PanoViewer/index.umd.ts", + output: "./dist/view360.panoviewer.min.js", + format: "umd", + commonjs: true, + uglify: true, + external, + }, + { + name, + input: "./src/SpinViewer/index.umd.ts", + output: "./dist/view360.spinviewer.min.js", + format: "umd", + commonjs: true, + uglify: true, + external, + }, + { + name, + input: "./src/index.umd.ts", + output: "./dist/view360.pkgd.js", + format: "umd", + commonjs: true, + resolve: true, + }, + { + name, + input: "./src/PanoViewer/index.umd.ts", + output: "./dist/view360.panoviewer.pkgd.js", + format: "umd", + commonjs: true, + resolve: true, + }, + { + name, + input: "./src/SpinViewer/index.umd.ts", + output: "./dist/view360.spinviewer.pkgd.js", + format: "umd", + commonjs: true, + resolve: true, + }, + { + name, + input: "./src/index.umd.ts", + output: "./dist/view360.pkgd.min.js", + format: "umd", + commonjs: true, + resolve: true, + uglify: true, + }, + { + name, + input: "./src/PanoViewer/index.umd.ts", + output: "./dist/view360.panoviewer.pkgd.min.js", + format: "umd", + commonjs: true, + resolve: true, + uglify: true, + }, + { + name, + input: "./src/SpinViewer/index.umd.ts", + output: "./dist/view360.spinviewer.pkgd.min.js", + format: "umd", + commonjs: true, + resolve: true, + uglify: true, + }, + { + input: "./src/index.ts", + output: "./dist/view360.esm.js", + format: "esm", + exports: "named", + commonjs: true, + external, + }, ]); + diff --git a/src/PanoViewer/index.umd.ts b/src/PanoViewer/index.umd.ts new file mode 100644 index 000000000..84ef8efb3 --- /dev/null +++ b/src/PanoViewer/index.umd.ts @@ -0,0 +1,7 @@ +import PanoViewer from "./PanoViewer"; +import { VERSION } from "../version"; + +export default { + PanoViewer, + VERSION, +}; diff --git a/src/SpinViewer/index.umd.ts b/src/SpinViewer/index.umd.ts new file mode 100644 index 000000000..067a08ef9 --- /dev/null +++ b/src/SpinViewer/index.umd.ts @@ -0,0 +1,9 @@ +import SpinViewer from "./SpinViewer"; +import SpriteImage from "./SpriteImage"; +import { VERSION } from "../version"; + +export default { + SpinViewer, + SpriteImage, + VERSION, +} diff --git a/src/index.ts b/src/index.ts index 952591927..1c78b9634 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ import PanoViewer from "./PanoViewer/PanoViewer"; -import { SpinViewer, SpriteImage } from "./SpinViewer/index"; +import { SpinViewer, SpriteImage } from "./SpinViewer"; import { VERSION } from "./version"; export { diff --git a/src/index.umd.ts b/src/index.umd.ts new file mode 100644 index 000000000..0fa111b91 --- /dev/null +++ b/src/index.umd.ts @@ -0,0 +1,10 @@ +import PanoViewer from "./PanoViewer/PanoViewer"; +import { SpinViewer, SpriteImage } from "./SpinViewer"; +import { VERSION } from "./version"; + +export default { + PanoViewer, + SpinViewer, + SpriteImage, + VERSION +};