Skip to main content
100%

Transform import statement

✓ Published0🌍 Public
Aalbertojg
Last edited Dec 9, 2016
Created on Dec 9, 2016

This example shows a code-modification workflow that rewrites JavaScript import statements by mapping component names to their file paths. It uses jscodeshift to parse source files into abstract syntax trees, filter import declarations from `components` or `component-library`, and replace them with direct path imports. The process generates path mappings from export declarations in index files, combines them into a single JSON dictionary, and then applies the transformation via the `transform-import.js` script, which leverages `jscodeshift`’s `ImportDeclaration` finder and `replaceWith` API. The run.sh script orchestrates the entire pipeline using npm scripts and Node.js file operations.

AI-generated description
UNLICENSED Licensed

Similar vizzes