@ampproject/remapping
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@jridgewell/gen-mapping | 0.3.5 | 79.68 kB | MIT | prod | |
@jridgewell/trace-mapping | 0.3.25 | 165.36 kB | MIT | prod |
The "@ampproject/remapping" is an npm package available at the URL git+https://github.com/ampproject/remapping.git. This JavaScript tool enables developers to remap sequential sourcemaps through transformations to reference the original source code. When your code is subjected to transformations like minification, bundling with webpack, or Babel transpilation, the resultant sourcemaps can still point to the correct locations in your original code. This greatly simplifies the process of building custom transformations.
Utilizing "@ampproject/remapping" requires the installation of the package through npm, which can be accomplished by running npm install @ampproject/remapping
. Once installed, you typically use it through a remapping
function that takes the final output sourcemap and a loader
function as parameters. For every source file pointer in the sourcemap, the loader
will be invoked with the resolved path. If the path represents a transformed file with its own sourcemap, the loader
should return this sourcemap. Otherwise, the path will be treated as an original, untransformed source code location.
Here's a simple example of how you use "@ampproject/remapping" in your JavaScript:
function remapping(
map: SourceMap | SourceMap[],
loader: (file: string, ctx: LoaderContext) => (SourceMap | null | undefined),
options?: { excludeContent: boolean, decodedMappings: boolean }
): SourceMap;
The map parameter is the final output sourcemap. The loader function will be called for every source file pointer in the sourcemap, and if the file path represents a transformed file, then the loader should return that sourcemap.
const remapped = remapping(
minifiedTransformedMap,
(file, ctx) => {
if (file === 'transformed.js') {
return transformedMap;
}
return null;
}
);
console.log(remapped);
The "@ampproject/remapping" documentation is included within the project's README file in its GitHub repository which can be accessed at https://github.com/ampproject/remapping. The README provides information about installation, usage examples, options and parameters related to the packages' features. The comprehensive documentation can guide developers through using the package effectively in their own projects. It serves as a valuable resource for gaining insights into the package's functionality and utilization.