Skip to content

Commit

Permalink
Add named export for Lightning in the ESM build
Browse files Browse the repository at this point in the history
Fixes #480
  • Loading branch information
frank-weindel committed May 18, 2023
1 parent 2e4c829 commit 7b16855
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
"version": "2.10.0",
"license": "Apache-2.0",
"type": "module",
"types": "dist/index.d.ts",
"types": "dist/src/lightning.esm.d.mts",
"module": "dist/lightning.esm.js",
"main": "dist/lightning.js",
"exports": {
".": {
"import": {
"types": "./dist/index.d.ts",
"types": "./dist/src/lightning.esm.d.mts",
"default": "./dist/lightning.esm.js"
},
"require": {
"types": "./dist/index.d.ts",
"types": "./dist/src/lightning.d.mts",
"default": "./dist/lightning.js"
}
},
Expand Down
27 changes: 27 additions & 0 deletions src/lightning.esm.d.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Metrological
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Special entrypoint for the ESM build that exports Lightning as both
* a default and named export.
* @module
*/
import Lightning from './lightning.mjs';

export default Lightning;
export { Lightning };
27 changes: 27 additions & 0 deletions src/lightning.esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the
* following copyright and licenses apply:
*
* Copyright 2023 Metrological
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* Special entrypoint for the ESM build that exports Lightning as both
* a default and named export.
* @module
*/
import Lightning from './lightning.mjs';

export default Lightning;
export { Lightning };
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const isMinifiedBuild = process.env.BUILD_MINIFY === 'true';
const isInspectorBuild = process.env.BUILD_INSPECTOR === 'true';

let outDir = 'dist';
let entry = resolve(__dirname, 'src/lightning.mjs');
let entry = resolve(__dirname, isEs5Build ? 'src/lightning.mjs' : 'src/lightning.esm.mjs');
let outputBase = 'lightning';
let sourcemap = true;
let useDts = true;
Expand Down

0 comments on commit 7b16855

Please sign in to comment.