From ce382d6dd3c80770d7d89dd0dde6a6580da34235 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Harrtell?= Date: Tue, 30 Aug 2022 01:37:43 +0200 Subject: [PATCH] [TS/JS] Add rollup and config to generate iife flatbuffers bundle (#7449) * Add rollup and config to generate iife flatbuffers bundle * Atempt to use yarn and add deps Co-authored-by: Derek Bailey --- .github/workflows/build.yml | 4 +++- package.json | 3 ++- rollup.config.js | 8 ++++++++ yarn.lock | 12 ++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 rollup.config.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c8f849df1..d8bb7bffd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -446,8 +446,10 @@ jobs: - name: flatc # FIXME: make test script not rely on flatc run: cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DFLATBUFFERS_BUILD_TESTS=OFF -DFLATBUFFERS_INSTALL=OFF -DFLATBUFFERS_BUILD_FLATLIB=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF . && make -j + - name: deps + run: yarn - name: compile - run: npm run compile + run: yarn compile - name: test working-directory: tests run: python3 TypeScriptTest.py diff --git a/package.json b/package.json index 427410e83..b805d864e 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ }, "scripts": { "test": "npm run compile && cd tests && python3 ./TypeScriptTest.py", - "compile": "tsc && tsc -p tsconfig.mjs.json", + "compile": "tsc && tsc -p tsconfig.mjs.json && rollup -c", "prepublishOnly": "npm install --only=dev && npm run compile" }, "repository": { @@ -40,6 +40,7 @@ "@typescript-eslint/eslint-plugin": "^4.12.0", "@typescript-eslint/parser": "^4.12.0", "eslint": "^7.17.0", + "rollup": "^2.78.0", "typescript": "^4.5.5" } } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 000000000..9369655e6 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,8 @@ +export default { + input: 'mjs/index.js', + output: { + file: 'flatbuffers.js', + format: 'iife', + name: 'flatbuffers' + } +} \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index 171854d3f..a1d9ed0c1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -624,6 +624,11 @@ fs.realpath@^1.0.0: resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= +fsevents@~2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" + integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== + functional-red-black-tree@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" @@ -945,6 +950,13 @@ rimraf@^3.0.2: dependencies: glob "^7.1.3" +rollup@^2.78.0: + version "2.78.0" + resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.78.0.tgz#00995deae70c0f712ea79ad904d5f6b033209d9e" + integrity sha512-4+YfbQC9QEVvKTanHhIAFVUFSRsezvQF8vFOJwtGfb9Bb+r014S+qryr9PSmw8x6sMnPkmFBGAvIFVQxvJxjtg== + optionalDependencies: + fsevents "~2.3.2" + run-parallel@^1.1.9: version "1.2.0" resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee"