-
Notifications
You must be signed in to change notification settings - Fork 24.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify
File
type: map
is nullable, but not optional
Summary: Simplifies the `File` type by making `map` a non-optional, but nullable property. Also adds helper functions for empty/virtual modules Reviewed By: jeanlauliac Differential Revision: D5111580 fbshipit-source-id: 9cab6634a9bdb0522dc36aec2abccaef9cf35339
- Loading branch information
1 parent
918bae2
commit 6b2122b
Showing
6 changed files
with
35 additions
and
21 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,28 @@ | |||
/** | |||
* Copyright (c) 2016-present, Facebook, Inc. | |||
* All rights reserved. | |||
* | |||
* This source code is licensed under the BSD-style license found in the | |||
* LICENSE file in the root directory of this source tree. An additional grant | |||
* of patent rights can be found in the PATENTS file in the same directory. | |||
* | |||
* @flow | |||
*/ | |||
'use strict'; | |||
|
|||
|
|||
import type {Module} from './types.flow'; | |||
|
|||
exports.empty = (): Module => virtual(''); | |||
|
|||
// creates a virtual module (i.e. not corresponding to a file on disk) | |||
// with the given source code. | |||
const virtual = exports.virtual = (code: string): Module => ({ | |||
dependencies: [], | |||
file: { | |||
code, | |||
map: null, | |||
path: '', | |||
type: 'script', | |||
}, | |||
}); |
This file contains 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
This file contains 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