This repository was archived by the owner on Apr 16, 2020. It is now read-only.
  
  
  - 
          
- 
                Notifications
    You must be signed in to change notification settings 
- Fork 19
esm: scoped --type, cpp refactoring #57
          
     Closed
      
      
    
                
     Closed
            
            
          Conversation
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
    Refs: nodejs/modules#180 PR-URL: nodejs#6 Reviewed-By: Myles Borins <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Refs: nodejs/modules#180 PR-URL: nodejs#6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Refs: nodejs/modules#180 PR-URL: nodejs#6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
Refs: nodejs/modules#180 PR-URL: nodejs#6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
PR-URL: nodejs#6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: John-David Dalton <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
PR-URL: nodejs#6 Reviewed-By: Guy Bedford <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
This reverts commit 1b0695b.
| I think I am in favor of less "virtual package json" magic, so... -0 | 
3e26030    to
    484d1fb      
    Compare
  
    484d1fb    to
    7efc53d      
    Compare
  
    c7fa700    to
    d69f765      
    Compare
  
    335d584    to
    9a343ce      
    Compare
  
    3a00b51    to
    bc101f6      
    Compare
  
    fd5b55a    to
    3a40599      
    Compare
  
    6fe40a4    to
    d9cdfd8      
    Compare
  
    
  
      Sign up for free
      to subscribe to this conversation on GitHub.
      Already have an account?
      Sign in.
  
      
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
With the current implementation, there is an edge case of
--typethat doesn't quite work out.Consider:
main.js
where
dep.jsis also an ECMAScript module.Currently,
node --type=module main.jswill execute main.js as an ECMAScript module, but then when it loads dep.js it forgets the type flag and goes back to the old rules of CJS treatment, which is usually not the intention.This PR fixes this case by having the top-level
--typeflag apply as a scope on the folder of the entry point.I ended up refactoring the type errors and ESM_FORMAT implementation in the process, making both more consistent as a result while retaining the same implementation behaviours as previously. Moving ESM_FORMAT back into the C++ code in the process also fixes the TODO on the package.json cache sharing issue.
I've also updated the spec on how the
--typeflag works to reflect the above, and also fixed some spec bugs where it wasn't quite aligning with our implementation in that files without an extension that weren't the main were still being permitted.