From 0e8a21854caffb978046e33ffeb26b60af9de31c Mon Sep 17 00:00:00 2001 From: Paul Taylor Date: Fri, 1 Dec 2017 14:18:43 -0800 Subject: [PATCH] publish additional js/flatbuffers.mjs to npm to support ESModules in node (#4504) --- .gitignore | 1 + package.json | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 9c8393b08..9dd3f498b 100644 --- a/.gitignore +++ b/.gitignore @@ -81,3 +81,4 @@ android/build/ samples/android/.externalNativeBuild/ samples/android/.gradle/ samples/android/build/ +js/flatbuffers.mjs \ No newline at end of file diff --git a/package.json b/package.json index dc767154d..65169c0f9 100644 --- a/package.json +++ b/package.json @@ -2,14 +2,17 @@ "name": "flatbuffers", "version": "1.8.0", "description": "Memory Efficient Serialization Library", - "files": ["js/flatbuffers.js"], - "main": "js/flatbuffers.js", + "files": ["js/flatbuffers.js", "js/flatbuffers.mjs"], + "main": "js/flatbuffers", + "module": "js/flatbuffers.mjs", "directories": { "doc": "docs", "test": "tests" }, "scripts": { - "test": "tests/JavaScriptTest.sh" + "test": "tests/JavaScriptTest.sh", + "append-esm-export": "sed \"s/this.flatbuffers = flatbuffers;/export { flatbuffers };/\" js/flatbuffers.js >> js/flatbuffers.mjs", + "prepublishOnly": "npm run append-esm-export" }, "repository": { "type": "git",