(Solved) How Can I ensure import in js?
gaki2 opened this issue · comments
Byeonggak Yu commented
I want to make a condition saying that
if CommonButton
is imported from '@miri-unicorn/miricanvas-ds', then ~~~~.
engine marzano(0.1)
language js
`CommonButton` as $common_button where {
and {
$base = `@miri-unicorn/miricanvas-ds`,
// this is not working.
$common_button <: imported_from($base),
// Below code is not working even though I imported { CommonButton } from '@miri-unicorn/miricanvas-ds'.
$common_button <: remove_import($base),
$button = `Button`,
$source = `@miri-unicorn/miricanvas-ds/v2`,
$button <: ensure_import_from($source),
}
}
Is there any pattern i can use?
imported_from
pattern seems to be not working.
Morgante Pell commented
You need to include the quotes:
engine marzano(0.1)
language js
`CommonButton` as $common_button where {
$base = `'@miri-unicorn/miricanvas-ds'`,
// this is not working.
$common_button <: imported_from($base),
$common_button <: remove_import($base),
$button = `Button`,
$source = `@miri-unicorn/miricanvas-ds/v2`,
$button <: ensure_import_from($source),
}
유병각 commented
Morgante Pell commented
We need to improve documentation for our utility patterns. For now the best resource is probably just looking at the code itself: https://github.com/getgrit/stdlib/blob/bc2aad90806268020ba5d610cc2092abbf4e0484/.grit/patterns/js/imports.grit#L15