-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add @parcel/macros package with macro context TS definitions (#9544)
- Loading branch information
1 parent
ac43c39
commit 78fe2ce
Showing
3 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
export interface MacroContext { | ||
/** Adds an asset as a dependency of the JS module that called this macro. */ | ||
addAsset(asset: MacroAsset): void; | ||
/** Invalidate the macro call whenever the given file changes. */ | ||
invalidateOnFileChange(filePath: string): void; | ||
/** Invalidate the macro call when a file matching the given pattern is created. */ | ||
invalidateOnFileCreate(options: FileCreateInvalidation): void; | ||
/** Invalidate the macro whenever the given environment variable changes. */ | ||
invalidateOnEnvChange(env: string): void; | ||
/** Invalidate the macro whenever Parcel restarts. */ | ||
invalidateOnStartup(): void; | ||
/** Invalidate the macro on every build. */ | ||
invalidateOnBuild(): void; | ||
} | ||
|
||
export interface MacroAsset { | ||
/** The type of the asset (e.g. `'css'`). */ | ||
type: string; | ||
/** The content of the asset. */ | ||
content: string; | ||
} | ||
|
||
export type FileCreateInvalidation = | ||
| FileInvalidation | ||
| GlobInvalidation | ||
| FileAboveInvalidation; | ||
|
||
/** Invalidate when a file matching a glob is created. */ | ||
export interface GlobInvalidation { | ||
glob: string; | ||
} | ||
|
||
/** Invalidate when a specific file is created. */ | ||
export interface FileInvalidation { | ||
filePath: string; | ||
} | ||
|
||
/** Invalidate when a file of a specific name is created above a certain directory in the hierarchy. */ | ||
export interface FileAboveInvalidation { | ||
fileName: string; | ||
aboveFilePath: string; | ||
} |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "@parcel/macros", | ||
"version": "2.11.0", | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/parcel" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/parcel-bundler/parcel.git" | ||
}, | ||
"types": "macros.d.ts", | ||
"sideEffects": false, | ||
"engines": { | ||
"node": ">= 12.0.0", | ||
"parcel": "^2.11.0" | ||
} | ||
} |