Skip to content

Commit

Permalink
fix: use latest d2-app-scripts to build tree-shakable library (#840)
Browse files Browse the repository at this point in the history
* fix: use latest d2-app-scripts to build tree-shakable library

* fix: upgrade all dhis2 dependencies

* fix: correctly merge babel configurations

* chore: correct jest ignore patterns
  • Loading branch information
amcgee authored Mar 11, 2021
1 parent ae0b60e commit 6720546
Show file tree
Hide file tree
Showing 6 changed files with 140 additions and 359 deletions.
7 changes: 0 additions & 7 deletions .storybook/.babelrc.js

This file was deleted.

27 changes: 27 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
const makeBabelConfig = require('@dhis2/cli-app-scripts/config/makeBabelConfig.js')

module.exports = {
addons: ['@storybook/preset-create-react-app'],
stories: ['../src/**/*.stories.@(js|mdx)'],
babel: async config => {
// currently styled-jsx is configured the same way for prod and
// dev so it doesn't matter what the mode is here.
const mode = 'production'

const custom = makeBabelConfig({
moduleType: 'es',
mode,
})

// ensure that our custom babel configuration is merged properly
// with the storybook babel configuration.
return {
...config,
presets: [
...config.presets,
...custom.presets,
],
plugins: [
...config.plugins,
...custom.plugins,
...custom.env[mode].plugins,
],
}
}
}
2 changes: 1 addition & 1 deletion d2.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const config = {
type: 'lib',

entryPoints: {
lib: './src/index',
lib: './src/index.js',
},
}

Expand Down
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
module.exports = {
testPathIgnorePatterns: ['/node_modules/', '/build/'],
setupFilesAfterEnv: ['<rootDir>/config/setupEnzyme.js'],
}
31 changes: 16 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
"name": "@dhis2/analytics",
"version": "16.0.12",
"main": "./build/cjs/lib.js",
"module": "./build/es/lib.js",
"main": "./build/cjs/index.js",
"module": "./build/es/index.js",
"exports": {
"import": "./build/es/index.js",
"require": "./build/cjs/index.js"
},
"sideEffects": [
"./src/locales/index.js"
"./build/es/locales/index.js",
"./build/cjs/locales/index.js"
],
"repository": "[email protected]:dhis2/analytics.git",
"author": "Jennifer Jones Arnesen <[email protected]>",
Expand All @@ -26,11 +31,11 @@
"validate-push": "yarn test"
},
"devDependencies": {
"@dhis2/app-runtime": "^2.6.1",
"@dhis2/cli-app-scripts": "^5.5.1",
"@dhis2/app-runtime": "^2.8.0",
"@dhis2/cli-app-scripts": "^6.0.0",
"@dhis2/cli-style": "^7.2.2",
"@dhis2/d2-i18n": "^1.0.6",
"@dhis2/ui": "^6.5.1",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/ui": "^6.5.3",
"@sambego/storybook-state": "^2.0.1",
"@storybook/addons": "^6.1.14",
"@storybook/preset-create-react-app": "^3.1.5",
Expand All @@ -43,9 +48,9 @@
"typeface-roboto": "^0.0.75"
},
"peerDependencies": {
"@dhis2/app-runtime": "^2.6.1",
"@dhis2/d2-i18n": "^1.0.6",
"@dhis2/ui": "^6.5.1",
"@dhis2/app-runtime": "^2",
"@dhis2/d2-i18n": "^1.1",
"@dhis2/ui": "^6.5.2",
"prop-types": "^15",
"react": "^16.3",
"react-dom": "^16.3",
Expand All @@ -69,9 +74,5 @@
},
"files": [
"build"
],
"resolutions": {
"@dhis2/ui": "^6.5.0",
"styled-jsx": "3.3.2"
}
]
}
Loading

0 comments on commit 6720546

Please sign in to comment.