Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ESM support #30

Merged
merged 9 commits into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
module.exports = {
presets: ['@babel/preset-env', '@babel/preset-typescript'],
env: {
esm: {
presets: [
[
'@babel/env',
{
modules: false,
},
],
],
},
},
};
46 changes: 25 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,27 @@
"url": "https://github.com/storybookjs/addon-svelte-csf"
},
"license": "MIT",
"main": "dist/preset",
"browser": "dist/index.js",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"browser": "dist/cjs/index.js",
"files": [
"dist/**/*",
"README.md",
"*.js"
"*.js",
"*.d.ts"
],
"scripts": {
"clean": "rimraf ./dist",
"build": "babel ./src --out-dir ./dist --extensions .ts --extensions .js --copy-files",
"prepublish": "npm run clean && npm run build",
"build": "concurrently \"yarn build:cjs\" \"yarn build:esm\"",
"build:cjs": "babel ./src -d ./dist/cjs --extensions \".js,.ts\" --copy-files",
"build:esm": "babel ./src -d ./dist/esm --env-name esm --extensions \".js,.ts\" --copy-files",
"prepublish": "yarn clean && yarn build",
"test": "jest",
"lint": "eslint --cache --cache-location=.cache/eslint --ext .js,.jsx,.json,.html,.ts,.tsx,.mjs --report-unused-disable-directives",
"storybook": "start-storybook -p 6006",
"start": "concurrently \"npm run storybook -- --no-manager-cache --quiet\" \"npm run build -- --watch\"",
"start": "concurrently \"yarn storybook -- --no-manager-cache --quiet\" \"yarn build -- --watch\"",
"build-storybook": "build-storybook",
"release": "npm run build && auto shipit --base-branch=main"
"release": "yarn && auto shipit --base-branch=main"
},
"dependencies": {
"ts-dedent": "^2.0.0"
Expand All @@ -38,16 +42,16 @@
"@babel/preset-env": "^7.12.1",
"@babel/preset-react": "^7.12.5",
"@babel/preset-typescript": "^7.12.5",
"@storybook/addon-essentials": "^6.2.1",
"@storybook/addon-knobs": "^6.2.1",
"@storybook/addon-storyshots": "^6.2.1",
"@storybook/eslint-config-storybook": "^2.4.0",
"@storybook/svelte": "^6.2.1",
"@storybook/addon-essentials": "^6.2.9",
"@storybook/addon-knobs": "^6.2.9",
"@storybook/addon-storyshots": "^6.2.9",
"@storybook/eslint-config-storybook": "^3.0.0",
"@storybook/svelte": "^6.2.9",
"auto": "^10.3.0",
"babel-jest": "^26.6.3",
"babel-loader": "^8.1.0",
"chromatic": "^5.6.1",
"concurrently": "^5.3.0",
"concurrently": "^6.2.0",
"eslint": "^7.17.0",
"jest": "^26.6.3",
"jest-environment-jsdom-thirteen": "^1.0.1",
Expand All @@ -61,14 +65,14 @@
"typescript": "^3.3.3333"
},
"peerDependencies": {
"@storybook/addons": "^6.2.1",
"@storybook/api": "^6.2.1",
"@storybook/client-api": "^6.2.1",
"@storybook/client-logger": "^6.2.1",
"@storybook/components": "^6.2.1",
"@storybook/core-events": "^6.2.1",
"@storybook/svelte": "^6.2.1",
"@storybook/theming": "^6.2.1",
"@storybook/addons": "^6.2.9",
"@storybook/api": "^6.2.9",
"@storybook/client-api": "^6.2.9",
"@storybook/client-logger": "^6.2.9",
"@storybook/components": "^6.2.9",
"@storybook/core-events": "^6.2.9",
"@storybook/svelte": "^6.2.9",
"@storybook/theming": "^6.2.9",
"react": "^16.8.0 || ^17.0.0",
"react-dom": "^16.8.0 || ^17.0.0",
"svelte": "^3.35.0",
Expand Down
2 changes: 1 addition & 1 deletion preset.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = require('./dist/preset');
module.exports = require('./dist/cjs/preset');
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
export { default as Meta } from './components/Meta.svelte';
export { default as Story } from './components/Story.svelte';
export { default as Template } from './components/Template.svelte';

if (module && module.hot && module.hot.decline) {
module.hot.decline();
}

// make it work with --isolatedModules
export default {};
Loading