Skip to content
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

Overhaul regex for styleUrls #10

Merged
merged 3 commits into from
Apr 5, 2017
Merged

Overhaul regex for styleUrls #10

merged 3 commits into from
Apr 5, 2017

Conversation

thymikee
Copy link
Owner

@thymikee thymikee commented Apr 5, 2017

Summary
Broader regex for styleUrls handling.
Fixes #9.

Test plan
Test cases I used:

@Component({
  selector: 'xc-media-box-h0',
  templateUrl: './media-box-h0.component.html',
  styleUrls: [ '../media-box.component.scss' ],
})

@Component({
  selector: 'xc-media-box-h0',
  templateUrl: './media-box-h0.component.html',
  styleUrls: ['../media-box.component.scss',
  './media-box-h0.component.scss'],
})

@Component({
  selector: 'xc-media-box-h0',
  templateUrl: './media-box-h0.component.html',
  styleUrls: [
    '../media-box.component.scss',
  ],
})

@Component({
  selector: 'xc-media-box-h0',
  templateUrl: './media-box-h0.component.html',
  styleUrls: [
    '../media-box.component.scss',
    './media-box-h0.component.scss'
  ],
})

@thymikee
Copy link
Owner Author

thymikee commented Apr 5, 2017

@intellix I've added tests for the cases you provided and they pass.

@intellix
Copy link
Contributor

intellix commented Apr 5, 2017

It all seems to work for me now as well actually :P LGTM!

@thymikee thymikee merged commit f6cbde3 into master Apr 5, 2017
@thymikee thymikee deleted the styleurl-regex branch April 5, 2017 13:46
@thinkricardo
Copy link

I've encountered a situation where this issue still occurs.

Example:
styleUrls: [ './a.component.scss', '../b.css', '../c.css' ]
It appears that having more than 2 lines corrupts the regex. If only 2 lines exist than it seems fine.

I'm using Prettier which formats the code putting the styles in each line and after that Jest stops working and throws SyntaxError (_normalizeTemplateMetadata).

@thymikee
Copy link
Owner Author

Happy to accept PR fixing that!

Now that babel supports typescript (in beta) we're technically able to make it properly by transforming ast instead of regex, so that's what I hope to do or review ;) soon

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.

3 participants