Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Dynamic import resulting in TypeError: Cannot read property 'name' of null #441

Closed
lorengreenfield opened this issue May 31, 2018 · 3 comments

Comments

@lorengreenfield
Copy link

Version: 3.0.41

This looks like it's related, or the same issue as #434
When doing a dynamic import like this:

import('/Users/loren/Sites/resortsinteractive/resorts-interactive.com/server/routes/api/emails/index.mjs')
    .then(output => {
      console.log(output)
    })
    .catch(err => {
      console.log(err)
    })

If the /Users/loren/Sites/resortsinteractive/resorts-interactive.com/server/routes/api/emails/index.mjs file has a default export that is an anonymous function, you get TypeError: Cannot read property 'name' of null

Anonymous functions have the issue:

export default function(server) {
    console.log('test')
}

Named functions are fine:

export default function email(server) {
    console.log('test')
}

Arrow functions are fine:

export default server => {
    console.log('test')
}

Here's the stack from the caught error:

    at module.exports.R.inited.R.module.errorCaptureStackTrace (/Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:42843)
    at Sl.d.hint (/Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:199978)
    at Sl (/Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:199999)
    at Module.g (/Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:210375)
    at Module.u._compile (/Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:62993)
    at Object.u (/Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:210807)
    at Object.l (/Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:209966)
    at Object.<anonymous> (/Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:207620)
    at /Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:69101
    at Yi.b (/Users/loren/Sites/resortsinteractive/resorts-interactive.com/node_modules/esm/esm.js:1:69136)```
@jdalton jdalton added the bug label May 31, 2018
@jdalton
Copy link
Member

jdalton commented May 31, 2018

Thanks @lorengreenfield!

@lorengreenfield
Copy link
Author

Likewise @jdalton - your work on this project is much appreciated. I think I speak for everyone when I say that!

@lorengreenfield
Copy link
Author

Awesome - all fixed in v3.0.42 it seems

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants