Skip to content

Failed import with Paste icon in Jest #1589

Answered by HartiganHM
HartiganHM asked this question in Q&A
Discussion options

You must be logged in to vote

Re-posting here for more visibility outside of the nested comment thread:

Ultimate Solution

  • Built a custom resolver to point any esm icon dependencies to the corresponding cjs directories

    /**
     * We're creating our own module resolver for jest because it is having a
     * very hard time finding our monorepo packages.  When we import a `@paste`
     * package we use our own module resolution, otherwise we use the default
     * node one.
     *
     * @param {string} package
     * @param {*} details
     */
    function customResolver(package, details) {
      if (
        package.includes('@twilio-paste/') &&
        package.includes('icons') &&
        package.includes('esm')
      ) {
        const [start, end] = package.split('esm');
        

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
10 replies
@TheSisb
Comment options

@HartiganHM
Comment options

@SiTaggart
Comment options

@HartiganHM
Comment options

@HartiganHM
Comment options

Comment options

You must be logged in to vote
2 replies
@TheSisb
Comment options

@HartiganHM
Comment options

Answer selected by TheSisb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants