-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from fink-lang/import-explicit-ext
feat(import): support explicit file ext in import URLs and translate .fnk to .js
- Loading branch information
Showing
5 changed files
with
57 additions
and
25 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 |
---|---|---|
@@ -1,8 +1,28 @@ | ||
{callExpression, Import: async_import} = import '@babel/types' | ||
{ends_with, slice} = import '@fink/std-lib/str' | ||
|
||
|
||
|
||
resolve_ext = fn import_url: | ||
match import_url: | ||
ends_with ?, '.fnk': | ||
'${slice import_url, 0, -4}.js' | ||
else: | ||
import_url | ||
|
||
|
||
|
||
transform_import = fn node, {transform}: | ||
right = transform node.right | ||
right = match node.right: | ||
{type: 'string', exprs: [..., {type: 'string:text'}]}: | ||
[...exprs, url] = node.right.exprs | ||
|
||
transform dict: | ||
...node.right | ||
exprs: [...exprs, {...url, value: resolve_ext url.value}] | ||
else: | ||
transform node.right | ||
|
||
callExpression | ||
async_import _ | ||
[right] |
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
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