From 475dc8fafa401931678aa535170486c97a2aa3a2 Mon Sep 17 00:00:00 2001 From: Sebastiaan Marynissen Date: Tue, 28 Jan 2020 09:25:12 +0100 Subject: [PATCH 1/2] Implement conditional exports --- package.json | 4 ++++ utils/build/rollup.config.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/package.json b/package.json index 22367b49028330..ec78827d00e9e1 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,10 @@ "description": "JavaScript 3D library", "main": "build/three.js", "module": "build/three.module.js", + "exports": { + "require": "./build/three.js", + "import": "./build/three.mjs" + }, "types": "src/Three.d.ts", "repository": { "type": "git", diff --git a/utils/build/rollup.config.js b/utils/build/rollup.config.js index 2cf00fdb2a6da3..ac7bf7c34af02a 100644 --- a/utils/build/rollup.config.js +++ b/utils/build/rollup.config.js @@ -235,5 +235,19 @@ export default [ indent: '\t' } ] + }, + { + input: 'src/Three.js', + plugins: [ + glconstants(), + glsl(), + ], + output: [ + { + format: 'esm', + file: 'build/three.mjs', + indent: '\t' + } + ] } ]; From f2aecce0131575a227ff45048225f648abc7ac00 Mon Sep 17 00:00:00 2001 From: Sebastiaan Marynissen Date: Thu, 30 Jan 2020 09:01:23 +0100 Subject: [PATCH 2/2] Remove warning for require --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index ec78827d00e9e1..1726b815537fbe 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "main": "build/three.js", "module": "build/three.module.js", "exports": { - "require": "./build/three.js", - "import": "./build/three.mjs" + "import": "./build/three.mjs", + "default": "./build/three.js" }, "types": "src/Three.d.ts", "repository": {