Skip to content

Commit

Permalink
fix: add IntelliSense support for export (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacasonato authored Sep 7, 2020
1 parent 63aac9c commit 4a55262
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 1 deletion.
92 changes: 92 additions & 0 deletions core/import_enhanced.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ test("core / import_enhance: parseImportStatement", async () => {
path: "/",
},
},
{
imp: "import type {} from 'https://deno.land/std@/';",
expect: {
domain: "deno.land",
module: "std",
version: "latest",
path: "/",
},
},
// non semver verions
{
imp: "import {} from 'https://deno.land/std@1.0.0-alpha/';",
Expand Down Expand Up @@ -118,6 +127,89 @@ test("core / import_enhance: parseImportStatement", async () => {
path: "/",
},
},

{
imp: "export * from 'http://a.c/xx/a.ts'",
expect: {
domain: "a.c",
module: "xx",
version: "latest",
path: "/a.ts",
},
},
{
imp: "export * from 'http://deno.land/std@0.66.0/fs/copy.ts'",
expect: {
domain: "deno.land",
module: "std",
version: "0.66.0",
path: "/fs/copy.ts",
},
},
{
imp: "export * from 'https://deno.land/x/sha2@1.0.0/mod/sha224.ts'",
expect: {
domain: "deno.land",
module: "sha2",
version: "1.0.0",
path: "/mod/sha224.ts",
},
},
{
imp: "export type {} from 'https://deno.land/std@/';",
expect: {
domain: "deno.land",
module: "std",
version: "latest",
path: "/",
},
},
{
imp: "export {} from 'https://deno.land/std@/';",
expect: {
domain: "deno.land",
module: "std",
version: "latest",
path: "/",
},
},
// non semver verions
{
imp: "export {} from 'https://deno.land/std@1.0.0-alpha/';",
expect: {
domain: "deno.land",
module: "std",
version: "1.0.0-alpha",
path: "/",
},
},
{
imp: "export {} from 'https://deno.land/std@v1/';",
expect: {
domain: "deno.land",
module: "std",
version: "v1",
path: "/",
},
},
{
imp: "export {} from 'https://deno.land/x/@/';",
expect: {
domain: "deno.land",
module: "",
version: "latest",
path: "/",
},
},
{
imp: "export { } from 'https://deno.land/x/sq'",
expect: {
domain: "deno.land",
module: "sq",
version: "latest",
path: "/",
},
},
] as {
imp: string;
expect: { domain: string; module: string; version: string; path: string };
Expand Down
2 changes: 1 addition & 1 deletion core/import_enhanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ interface ImportUrlInfo {
path: string;
}

export const IMP_REG = /^.*?import.+?from.+?['"](?<url>[0-9a-zA-Z-_@~:/.?#:&=%+]*)/;
export const IMP_REG = /^.*?[import|export].+?from.+?['"](?<url>[0-9a-zA-Z-_@~:/.?#:&=%+]*)/;
export const VERSION_REG = /^([\w.\-_]+)$/;
export const MOD_NAME_REG = /^[\w-_]+$/;

Expand Down

0 comments on commit 4a55262

Please sign in to comment.