Skip to content

Add options to wildcard #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jan 31, 2018
Merged

Add options to wildcard #86

merged 10 commits into from
Jan 31, 2018

Conversation

CKGrafico
Copy link
Contributor

@CKGrafico CKGrafico commented Jan 10, 2018

Extend #77 (comment) PR
In progress adding @Toilal request

@Toilal
Copy link

Toilal commented Jan 10, 2018

In fact it should read tsconfig baseUrl and paths properties. In my use case, I have 2 wildcards ...

{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"],
      "#/*": ["app/*"]
    },
   ...
  }
}

(Library template, source files lies in src/* and demo app files lies in app/*)

@CKGrafico
Copy link
Contributor Author

Docs modified

@CKGrafico
Copy link
Contributor Author

mm @Toilal this will need more work let me..

@Toilal
Copy link

Toilal commented Jan 10, 2018

If it's not possible, maybe the option could accept an array ?

@Toilal
Copy link

Toilal commented Jan 10, 2018

Would it be possible to loop on options.paths items matching .*/\* (regex) until if finds a file for the requested moduleName ?

@CKGrafico
Copy link
Contributor Author

I have to change docs and two more minor things and it's done

@johnnyreilly
Copy link
Member

Good work! Could you take a look at the failing build please?

@CKGrafico
Copy link
Contributor Author

@johnnyreilly sorry I'm modifiyng my VueProgram.js and translating to your VueProgram.ts xDD

PS: mmm the test always the test haha give me some minutes

@CKGrafico
Copy link
Contributor Author

Your tests are not working for me on Windows because absoluth path returns C:/... but I hope are ok now

@johnnyreilly
Copy link
Member

For what it's worth, I'm a Windows guy but I use the Linux subsystem to run fork-ts-checker-webpack-plugin tests. @piotr-oles could you review this when you get a moment please?

@CKGrafico
Copy link
Contributor Author

But can you do it on another PR xD? Is not related with my changes

@johnnyreilly
Copy link
Member

Sorry - not sure I understand what you meant?

Either way - tests are passing now 😄

const pattern = options.paths ? options.paths['@/*'] : undefined;
const substitution = pattern ? options.paths['@/*'][0].replace('*', '') : 'src';
const isWildcard = moduleName.substr(0, 2) === '@/';
const discartedSymbols = ['.', '..', '/'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "discarted" meant to be "discarded" (misspelling)? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry

@@ -210,8 +210,7 @@ import Hello from '@/components/hello.vue'
}
```

6. The commonly used `@` path wildcard will work if you set up a `baseUrl` and `paths` (in `compilerOptions`) to include `@/*`. If you don't set this, then
the fallback for the `@` wildcard will be `[tsconfig directory]/src` (we hope to make this more flexible on future releases):
6. It accepts any wildcard in your TypeScript configuration:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have this, the wildcard option in fork-ts-checker-webpack-plugin` was dropped right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it looks like you dropped that option (good!) since I don't see it here in the final file changes. 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My fault I was using Github "online" haha and every change was a commit

@prograhammer
Copy link
Contributor

prograhammer commented Jan 10, 2018

@CKGrafico Looks good!

But I see you are going down the route I took too (trying to cover for the common cases). Let's hope there are no more folks giving us future wildcard issues before we beg Microsoft for an API in TypeScript to resolve those paths in tsconfig.json (or we'll finally tackle it ourselves!). 😨

@CKGrafico
Copy link
Contributor Author

Anybody needs something else?

@prograhammer
Copy link
Contributor

Looks good to me to merge! 🚀

@Toilal
Copy link

Toilal commented Jan 11, 2018

I experience something I can't understand (again :p)... Even without this change, my project is working properly with # as alias (It just runs 0.3.0 release). I can catch TSLint errors on some Vue component imported with # symbol.

You can reproduce this by running, this should raise errors in src/app/Dummy.vue

git clone https://github.com/Toilal/vue-webpack-template.git -b test-#-import test-import
cd test-import
npm i
npm run build

@Toilal
Copy link

Toilal commented Jan 11, 2018

@CKGrafico Could you test with #87 (https://github.com/Toilal/fork-ts-checker-webpack-plugin/tree/vue-non-ts-module-simple) ?

It seems that we can handle wildcard module names the same way we handle relative module name (by building the "full" module name). TypeScript is able to solve paths like /home/toilal/project/test-import/src/components/#/components/Dummy.vue making manual building from tsconfig just useless.

@prograhammer
Copy link
Contributor

@CKGrafico

I just ran your PR locally npm run test and I'm getting 2 fails. Anybody else getting this?

 [INTEGRATION] vue
    ✓ should create a Vue program config if vue=true (298ms)
    ✓ should not create a Vue program config if vue=false (239ms)
    ✓ should create a Vue program if vue=true (269ms)
    ✓ should not create a Vue program if vue=false (239ms)
    ✓ should get syntactic diagnostics from Vue program (254ms)
    1) should not find syntactic errors when checkSyntacticErrors is false
    2) should find syntactic errors when checkSyntacticErrors is true

@CKGrafico
Copy link
Contributor Author

I'm going to check asap.
@prograhammer Travis is working well isn't it? I had problems running this on windows (and other PRs of this project) but I will doublecheck

@Toilal
Copy link

Toilal commented Jan 11, 2018

@prograhammer I had this issue too. If you are using yarn, run yarn upgrade. (that's why yarn.lock has changed on #87)

@prograhammer
Copy link
Contributor

In the integration vue test, the example-wild.vue also needs a semantic error (this is good to have in the tests). So that line should be updated to:

public x: string = 1;

Then all passes. Weird that Travis didn't catch it?

@prograhammer
Copy link
Contributor

So the total is 3 errors. 2 semantic, and 1 syntactic.

@CKGrafico if you want to update that line in example-wild.vue in the integration test to be a semantic error (just like example.vue) in this PR then I think all is good.

@Toilal
Copy link

Toilal commented Jan 11, 2018

I'm pretty sure you don't run same TypeScript or TSLint version than the travis build.

@prograhammer
Copy link
Contributor

Ah @Toilal gotcha. Let me check that...

@prograhammer
Copy link
Contributor

Or maybe webpack is suddenly silent? I'm on my phone and can't get to my laptop til later tonight to check.

@CKGrafico
Copy link
Contributor Author

CKGrafico commented Jan 12, 2018

@Toilal not sure that your PR :/ will work to every SO
@prograhammer I'm testing this with yarn instead of npm and updating yarn.lock asap, sorry for forget yarn I'm not using it since package-lock.json exist

@CKGrafico
Copy link
Contributor Author

Checked if you don't use windows npm test is working well (The windows errors is not related with this PR we can merge this and made another one)

@Toilal
Copy link

Toilal commented Jan 12, 2018

I'll close my PR, it's simpler but only works magically in my project, with yours we are pretty sure it should work everywhere. Thanks a lot, it'll be included on my webpack template fork https://github.com/Toilal/vue-webpack-template when it's released in this library.

@CKGrafico
Copy link
Contributor Author

Test failing after I've updated yarn? amazing

@CKGrafico
Copy link
Contributor Author

Ok in index.spec something like this

console.log(stats.compilation.errors, stats.compilation.errors.length)

returns an array of '1' is not number and length 1 and you're expecting to be 1

but on vue.spec you have the same and you are expecting 2, I'm assuming that is a strange mistake? and correcting it

@prograhammer
Copy link
Contributor

prograhammer commented Jan 12, 2018

Yeah I think there might have been some extra Webpack output there, but with the latest package.json lock it seems to have gone away. (BTW, you guys should update to latest Node 8 (now LTS) and NPM 5 because NPM is as fast as Yarn now (and yarn is just another abstraction to learn on top of NPM anyway).

Anyways, all good to merge! 🚀

@Toilal
Copy link

Toilal commented Jan 12, 2018

From my experience it's still a bit slower. In fact. when there's a package-lock file, I use npm5, else I use Yarn.

@CKGrafico
Copy link
Contributor Author

I think the PR is ready now :)

@johnnyreilly
Copy link
Member

Cool - @piotr-oles could you review when you get a moment please?

@Toilal
Copy link

Toilal commented Jan 16, 2018

Could you have a look to #88 ? Not sure how it's related ...

@CKGrafico
Copy link
Contributor Author

Please is you're not to merge this soon, tell us and we will made a fork for our projects :D

@johnnyreilly
Copy link
Member

@piotr-oles could you take a look when you get a moment? @CKGrafico - until that time would you like me to publish it to our makeshift @next channel? https://github.com/TypeStrong/fork-ts-checker-webpack-plugin

@CKGrafico
Copy link
Contributor Author

Not the best but sounds like a solution 💃

@johnnyreilly
Copy link
Member

Give me an hour...

@johnnyreilly
Copy link
Member

Take a look: https://github.com/typestrong/fork-ts-checker-webpack-plugin

@CKGrafico
Copy link
Contributor Author

@johnnyreilly mmm I think that you're not using my PR xD CKGrafico@f9c01f9 --> d6ce069#diff-23d36b6fe597b409b93d20e36766ff64R31

@johnnyreilly
Copy link
Member

johnnyreilly commented Jan 17, 2018

Yup - I didn't build from the patch-1 branch. Doing that now.

@johnnyreilly
Copy link
Member

Is this better? 4fce3bd

@piotr-oles piotr-oles merged commit 840d0fd into TypeStrong:master Jan 31, 2018
@piotr-oles
Copy link
Collaborator

Thank you for your work and sorry for delay :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants