Closed tinyfly closed 5 years ago
I tried awhile back, ran into some weird issues and haven't had the need or time to get through them. Anyone else is welcome to try though.
@tyvdh do you have a copy of the error/logs that you were seeing when trying to publish this to NPM. Obviously its best that the package author publishes this onto NPM rather than say myself with my key/account
➜ txt2give-dashboard git:(master) ✗ npm i --save BaremetricsCalendar
txt2give-dashboard@1.0.0 /Users/cboyd/code/txt2give-dashboard
└── BaremetricsCalendar@1.0.8
webpack.config.js
:
module.exports = {
entry: {
vendor: [
'BaremetricsCalendar',
...
webpack -p
output:
ERROR in multi vendor
Module not found: Error: Cannot resolve module 'BaremetricsCalendar' in /Users/cboyd/code/txt2give-dashboard
@ multi vendor
Any ideas? Can't seem to get past this.
After tinkering, I think @tinyfly is correct. @tyvdh, you commented with the link to the npm repo but I still don't see a main
entry in package.json
. @warrenbuckley is right, it would be better for you to publish to the NPM repo if possible.
Btw, fixed using a webpack resolve alias:
webpack.config.js
:
module.exports = {
...
resolve: {
...
alias: {
'BaremetricsCalendar': path.join(__dirname, "node_modules", "BaremetricsCalendar", "public/js/Calendar.js"),
},
}
...
}
Still would be nice to have a main
entry. The documentation for webpack is kinda notorious for being a bit vague so it typically is hard to figure out workarounds like this.
Using webpack 2:
resolve: {
alias: {
BaremetricsCalendar: path.resolve('./node_modules/BaremetricsCalendar/public/js/Calendar.js'),
},
},
And inside your code:
import Calendar from 'BaremetricsCalendar'
@tyvdh Can this issue please be reopened? The aforementioned hack works for me, but I wish it wasn't needed.
I'll try and get to this once we hit our next bug sprint week in a couple weeks.
Just updated https://www.npmjs.com/package/baremetrics-calendar Give it a try when you get the chance!
Could you publish this to npm? I think the only thing that might be needed in package.json is a "main" entry pointing to your Calendar.js file.