Maybe someone can help me.
I am trying to publish an npm package with the following configuration:
Webpack:
production: {
entry: [
'./src',
'./src/app.scss',
'draft-js/dist/Draft.css'
],
devtool: "source-map",
output: {
path: path.join(__dirname, 'lib'),
filename: 'stewie-editor.js',
library: 'stewie-editor',
libraryTarget: 'umd',
umdNamedDefine: true
}
},
library publishing section of package.json
"main": "lib/stewie-editor.js",
"files": [
"lib",
"src"
],
My src / index.js file looks like this:
import EditorComponent from 'EditorComponent';
import EditorFactory from 'EditorFactory';
export {
EditorFactory,
EditorComponent
}
.babelrc
{
"presets": ["es2015", "stage-2", "react"],
"plugins": ["babel-plugin-add-module-exports"],
"env": {
"test": {
"plugins": [
["css-modules-transform", {
"generateScopedName": "[name]__[local]",
"extensions": [".css", ".scss"]
}]
]
},
"dev": {
"plugins": [["react-transform", {
"transforms": [{
"transform": "react-transform-hmr",
"imports": ["react"],
"locals": ["module"]
}]
}]]
}
}
}
I looked at the following example and everything works there.
strange with my setup things don't work
In another project, when I install the npm stewie-editor package and import the exported classes from the package as follows:
import { EditorFactory } from 'stewie-editor';
I get undefined. When I try to view the contents of the whole package, importing it like this:
import stewie from 'stewie-editor';
I get an empty object.
Your help will be greatly appreciated.