Skip to content

Commit

Permalink
feat(esm): include ESM and CommonJS builds (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbardini authored May 15, 2021
1 parent 0cdfe17 commit 76fbf7d
Show file tree
Hide file tree
Showing 18 changed files with 22,204 additions and 5,796 deletions.
14 changes: 0 additions & 14 deletions .babelrc

This file was deleted.

33 changes: 33 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const presetEnvOptions = {
bugfixes: true,
corejs: '3',
modules: false,
shippedProposals: true,
targets: 'defaults',
useBuiltIns: 'usage',
};

module.exports = {
assumptions: {
noDocumentAll: true,
privateFieldsAsProperties: true,
setClassMethods: true,
setComputedProperties: true,
setPublicClassFields: true,
setSpreadProperties: true,
},
env: {
cjs: {
presets: [
['@babel/preset-env', { ...presetEnvOptions, modules: 'cjs' }],
'@babel/preset-typescript',
'@babel/preset-react',
],
},
},
presets: [
['@babel/preset-env', presetEnvOptions],
'@babel/preset-typescript',
'@babel/preset-react',
],
};
5 changes: 3 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"node": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react/recommended",
"airbnb",
"prettier",
"prettier/react"
"prettier"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
Expand All @@ -31,6 +31,7 @@
],
"import/prefer-default-export": "off",
"no-undef": "off",
"no-unused-vars": "off",
"no-use-before-define": "off",
"react/jsx-filename-extension": [
"error",
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v2
with:
node-version: 12
node-version: 14

- name: Install
run: npm ci
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.DS_Store
.vscode
dist
node_modules
Expand Down
1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npx --no lint-staged
5 changes: 0 additions & 5 deletions .huskyrc

This file was deleted.

8 changes: 3 additions & 5 deletions bin/sb-playroom → bin/sb-playroom.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@ program
.option('-o, --out-file <path>', 'output file', 'snippets.json')
.option('-c, --config-file <path>', 'Babel config file')
.action((configDir = '.storybook', { configFile, ...options }) => {
require('@babel/register')({ configFile });
require('../dist/generateSnippets').default(configDir, options);
require('@babel/register')({ configFile, only: [new RegExp()] });
require('../dist/cjs/generateSnippets').default(configDir, options);
});

program
.version(version, '-v, --version')
.parse(process.argv);
program.version(version, '-v, --version').parse(process.argv);

if (program.rawArgs.length < 3) {
program.help();
Expand Down
14 changes: 7 additions & 7 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
"storybook": "start-storybook -s public -p 6006"
},
"dependencies": {
"react": "^17.0.0",
"react-dom": "^17.0.0"
"react": "^16.8.0",
"react-dom": "^16.8.0"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@storybook/addon-links": "^6.0.0",
"@storybook/addon-storysource": "^6.0.0",
"@storybook/addons": "^6.0.0",
"@storybook/react": "^6.0.0",
"@storybook/addon-links": "^6.2.0",
"@storybook/addon-storysource": "^6.2.0",
"@storybook/addons": "^6.2.0",
"@storybook/react": "^6.2.0",
"babel-loader": "^8.0.0",
"npm-run-all": "^4.0.0",
"playroom": "^0.22.0",
"playroom": "^0.23.0",
"storybook-addon-playroom": "file:../"
}
}
Loading

0 comments on commit 76fbf7d

Please sign in to comment.