-
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 #82 from fink-lang/optional-ext-transform
feat(import): improve file ext handling.
- Loading branch information
Showing
11 changed files
with
138 additions
and
61 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{fink2js} = import '../../testing' | ||
{describe, it, expect, to_match_snapshot} = import '@fink/jest' | ||
|
||
|
||
describe 'import', fn: | ||
it 'imports exported values', fn: | ||
expect | ||
fink2js " | ||
{bar} = import './spam.fnk' | ||
{foo: spam} = import './shrub.fnk' | ||
" | ||
to_match_snapshot | ||
|
||
|
||
it 'imports dynamically with static URL', fn: | ||
expect | ||
fink2js " | ||
ni = await import './shrub.fnk' | ||
" | ||
to_match_snapshot | ||
|
||
|
||
it 'imports with dynamic URLs', fn: | ||
expect | ||
fink2js " | ||
foo = bar + spam | ||
shrub = await import foo | ||
ni = await import '\${foo}' | ||
na = await import './\${foo}.fnk' | ||
" | ||
to_match_snapshot | ||
|
||
|
||
it 'imports without transforming ext', fn: | ||
expect | ||
fink2js | ||
" | ||
# | ||
{is_str} = import '@fink/std-lib/str.fnk' | ||
{bar} = import './spam.fnk' | ||
{foo: spam} = await import './shrub.fnk' | ||
na = await import './\${foo}.fnk' | ||
import './foo.fnk' | ||
ni = import '../ni.fnk' | ||
" | ||
{import: {ext: {rel: '.fnk', abs: '.js'}}} | ||
to_match_snapshot | ||
|
||
|
||
it 'imports module', fn: | ||
|
||
expect | ||
fink2js " | ||
import 'shrub' | ||
import '@fink/foo/bar.fnk' | ||
" | ||
to_match_snapshot | ||
|
||
|
||
it 'imports default export', fn: | ||
expect | ||
fink2js " | ||
foo = import './foo.fnk' | ||
" | ||
to_match_snapshot | ||
|
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`import imports default export 1`] = `"import foo from \\"./foo.js\\";"`; | ||
|
||
exports[`import imports dynamically with static URL 1`] = `"export const ni = await import(\`./shrub.js\`);"`; | ||
|
||
exports[`import imports exported values 1`] = ` | ||
"import { bar } from \\"./spam.js\\"; | ||
import { foo as spam } from \\"./shrub.js\\";" | ||
`; | ||
|
||
exports[`import imports module 1`] = ` | ||
"import \\"shrub\\"; | ||
import \\"@fink/foo/bar.js\\";" | ||
`; | ||
|
||
exports[`import imports with dynamic URLs 1`] = ` | ||
"export const foo = bar + spam; | ||
export const shrub = await import(foo); | ||
export const ni = await import(\`\${foo}\`); | ||
export const na = await import(\`./\${foo}.js\`);" | ||
`; | ||
|
||
exports[`import imports without transforming ext 1`] = ` | ||
"// | ||
import { is_str } from \\"@fink/std-lib/str.js\\"; | ||
import { bar } from \\"./spam.fnk\\"; | ||
const { | ||
\\"foo\\": spam | ||
} = await import(\`./shrub.fnk\`); | ||
export const na = await import(\`./\${foo}.fnk\`); | ||
import \\"./foo.fnk\\"; | ||
import ni from \\"../ni.fnk\\";" | ||
`; |
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