diff --git a/demo/index.html b/demo/index.html index a545ea66ed..d90fc5f3b7 100644 --- a/demo/index.html +++ b/demo/index.html @@ -11,7 +11,7 @@ - + diff --git a/package.json b/package.json index 6362dd59fe..f3161bfa84 100644 --- a/package.json +++ b/package.json @@ -13,27 +13,27 @@ "dist/*.xml" ], "scripts": { - "serve-static": "live-server --open=demo --watch=build/o_spreadsheet.dev.js,build/o_spreadsheet.xml,demo", - "dev": "npm-run-all --print-label buildDev --parallel server serve-static watch:*", + "serve-static": "live-server --open=demo --watch=build/o_spreadsheet.iife.js,build/o_spreadsheet.xml,demo", + "dev": "npm-run-all --print-label bundle:dev --parallel server serve-static watch", "server": "node tools/server/main.cjs", "build:js": "tsc --module es6 --incremental", - "build:bundleJsDev": "rollup -c -m --configDev", - "build:bundleJs": "rollup -c -m --configDist", - "build:bundleXml": "node tools/bundle_xml/main.cjs", - "buildDev": "npm-run-all build:js build:bundleJsDev \"build:bundleXml -- --outDir build\"", - "build": "npm-run-all build:js build:bundleJs \"build:bundleXml -- --outDir build\"", - "precommit": "npm run prettier && npm run doc", + "bundle:iife": "rollup -c -m -- --format iife", + "bundle:esm": "rollup -c -m -- --format esm", + "bundle:xml": "node tools/bundle_xml/main.cjs", + "bundle:dev": "npm-run-all build:js bundle:iife \"bundle:xml -- --outDir build\"", + "dist": "tsc --module es6 --declaration --declarationDir dist/types && rollup -c && npm run bundle:xml -- --outDir dist", "test": "tsc --noEmit --project tsconfig.jest.json && jest", "test:watch": "jest --watch", "prettier": "prettier . --write", "check-formatting": "prettier . --check", - "dist": "tsc --module es6 --declaration --declarationDir dist/types && rollup -c && npm run build:bundleXml -- --outDir dist", "prepare": "husky install", - "watch:bundle": "npm run build:bundleJsDev -- --watch", + "watch": "npm-run-all -p watch:*", + "watch:bundle": "npm run bundle:iife -- --watch", "watch:ts": "npm run build:js -- --watch", "watch:xml": "node tools/bundle_xml/watch_xml_templates.cjs", "unzipXlsx": "node tools/bundle_xlsx/unzip_xlsx_demo.cjs", - "zipXlsx": "node tools/bundle_xlsx/zip_xlsx_demo.cjs" + "zipXlsx": "node tools/bundle_xlsx/zip_xlsx_demo.cjs", + "build": "npm-run-all build:js bundle:esm \"bundle:xml -- --outDir build\"" }, "browserslist": [ "last 1 Chrome versions" diff --git a/rollup.config.js b/rollup.config.js index 1a13422e90..3585d20966 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -31,29 +31,22 @@ export default (commandLineArgs) => { let plugins = [nodeResolve()]; let config = {}; - if (commandLineArgs.configDev || commandLineArgs.configDist) { + if (commandLineArgs.format) { // Only build one version to improve speed - input = "build/js/index.js"; - output = [ - { - name: "o_spreadsheet", - extend: true, - outro, - banner: bundle.jsBanner(), - globals: { "@odoo/owl": "owl" }, - }, - ]; - if (commandLineArgs.configDev) { - output[0].file = `build/o_spreadsheet.dev.js`; - output[0].format = `iife`; - } else { - output[0].file = `build/o_spreadsheet.js`; - output[0].format = `esm`; - } config = { - input, + input: "build/js/index.js", external: ["@odoo/owl"], - output, + output: [ + { + name: "o_spreadsheet", + extend: true, + outro, + banner: bundle.jsBanner(), + globals: { "@odoo/owl": "owl" }, + file: `build/o_spreadsheet.${commandLineArgs.format}.js`, + format: commandLineArgs.format, + }, + ], plugins, }; } else {