[WIP] Refactored one-loader to allow more tags #53
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
After the discussions in #44 I have decided to look into it, and ended up refactoring the whole loader.
I did that with 3 goals:
Therefore, I've split
loader.js
into 2 new sub-loaders to make it more obvious what is happeningI've also renamed some variables and added a few comments
<template>
tagturned out to be a very simple 1 line change
<script>
tags)Tags now don't really matter much anymore. The only rule now is to have at least 1 script tag which will be the primary javascript (or typescript, coffee, ...) part (either the tag with
id="component"
or the first script tag). All other parts will be loaded into that viarequire()
regardless of tag.This now means that you could in theory even have
<script type="text/css">body { background: red; color: blue; }</script>
and it would load correctly via thecss-loader
&style-loader
because only the type attribute is used to decide what to do. It's silly, but it would work. Primary benefit of the tags now is just the different syntax highlighting in editors.Because it made sense in my refactoring, I also changed the return value of the parser, and thereby fixed #52
EDIT:
<template>
is actually not working as intended at the moment. We need to turn the parsed tree back into a string in order to work.This PR is not ready to be merged, but rather a request for review and comments
TODOs:
<template>
: turn tree object into string