fixed codesandbox relative to absolute imports #3538
Merged
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.
Closes #3525
This PR updates the conversion of relative import paths to absolute import paths, to be used in Codesandbox where the relative files aren't present.
Previously:
mdx-hast-to-jsxwould identify any relative imports in example code (import Something from '../Something.js'), parse out the name of the imported item, and build a map matching this relative imported item to the absolute import path for it{ Something: '@patternfly/some-package/Something.js' }codesandbox.jsto use simple string replacement to swap out the relative path with the absolute path in the example code before sending to Codesandbox exampleNow:
mdx-hast-to-jsxmaps the relative import path (not the name of the imported item) directly to the absolute import path{ '../../Something.js': '@patternfly/some-package/Something.js' }import { rows, columns } from '../../Data.js') - what is being imported doesn't really matter, we're just concerned with finding the relative file where it's coming from and getting the absolute path to that file.