Skip to content

import * broken? #49

@lheckemann

Description

@lheckemann

I've been having odd issues with my testing setup; I don't fully understand the problem, and haven't been able to reproduce it outside of a nix build, but I've been able to bisect the issue down to nodejs/node@68da144.

Unfortunately, I haven't been able to pare this down to a minimal reproducer, nor can I share the full project; I'm running firefox playwright tests against a project built with vite, and the breakage seems to boil down to a difference in how import * behaves in the code built by vite running in the browser, which seems pretty cursed!

My import looks like this:

import * as Chord from "@tonaljs/chord"

My code then uses Chord.get(), which works fine prior to this change and breaks afterwards with "Chord.get is not a function".

Logging the imported Chord object shed some light on the problem:

[Module: null prototype] {                                                                                                                                                                 
  chord: [Function (anonymous)],                                                                                                                                                           
  chordScales: [Function: chordScales],       
  default: {                                  
    chord: [Getter],                                                                                                                                                                       
    chordScales: [Getter],                                                                   
    default: [Getter],                        
    degrees: [Getter],                                                                       
    deprecate: [Getter],                                                                     
    detect: [Getter],                                                                        
    extended: [Getter],                                                                                                                                                                    
    get: [Getter],                                                                                                                                                                         
    getChord: [Getter],                                                                                                                                                                    
    reduced: [Getter],                                                                                                                                                                     
    steps: [Getter],                                                                                                                                                                       
    tokenize: [Getter],                                                                                                                                                                    
    transpose: [Getter]                                                                      
  },                                                                                                                                                                                       
  degrees: [Function: degrees],                                                                                                                                                            
  deprecate: [Function: deprecate],                                                                                                                                                        
  detect: [Function: detect],                                                                
  extended: [Function: extended],                                                            
  'module.exports': {                                                                        
    chord: [Getter],                                                                         
    chordScales: [Getter],                                                                                                                                                                 
    default: [Getter],                        
    degrees: [Getter],                                                                       
    deprecate: [Getter],                                                                     
    detect: [Getter],                                                                        
    extended: [Getter],                                                                                                                                                                    
    get: [Getter],                                                                                                                                                                         
    getChord: [Getter],                                                                                                                                                                    
    reduced: [Getter],                        
    steps: [Getter],                                                                         
    tokenize: [Getter],                                                                      
    transpose: [Getter]                                                                      
  }                                           
}          

so somehow module.exports isn't exposed directly anymore?

If anyone has any idea how this might be happening, it would be much appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions