jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.27k stars 507 forks source link

TypeError: _rrule2.default is undefined #552

Closed herndlm closed 1 year ago

herndlm commented 1 year ago

We did an update from 2.6.2 -> 2.7.1 in a vue.js application and this is what we get when the browser loads the JS which is bundled via gulp. We have some gulp transformations using browserify, babelify and vueify as in

return browserify({
        entries: '<path-to-app.js>',
        debug: isDevBuild,
    })
        .transform(babelify, {
            presets: ['env'],
            plugins: ['transform-object-rest-spread', 'transform-es2015-destructuring'],
        })
        .transform(vueify, {
            babel: {
                presets: ['es2015'],
                plugins: ['transform-runtime', 'transform-object-rest-spread', 'transform-es2015-destructuring'],
            }
        })
        .transform(
            { global: true },
            envify({ NODE_ENV: process.env.NODE_ENV })
        )
        .bundle()

I really don't expect that somebody can debug this based on the information I provided, that's fine. I just wanted to see if someone maybe recognizes the error and is like "yeah sure, you are doing x wrong" or smth like that or can point me in a direction. And I wonder why this broke in this minor update hmm. I tried to debug this once already but did not come far. Before the next try I wanted to reach out here.

herndlm commented 1 year ago

Writing this lead me to believe that browserify must somehow be the culprit and this whole thing should be migrated to something newer..

herndlm commented 1 year ago

Maybe those lines from the built JS are interesting too

var _rrule = require('rrule');

var _rrule2 = _interopRequireDefault(_rrule);

// .. other unrelated stuff ..

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

And the first failure apparently is

new _rrule2.default();

This all must surely have something to do with how things are loaded, ES modules and/or the named export changes?

herndlm commented 1 year ago

ok looks like I figured it out. I was so sure that I tried this already in the first debuging session.. Basically I had to do

-import RRule from 'rrule';
+import { RRule } from 'rrule'

and that makes highly sense..

It's just a bit dangerous to change this in a minor update I guess, I totally not expected this :D