question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Documentation for deprecated options

See original GitHub issue

What problem does this feature solve?

My issue doesn’t fit neatly within either Bug Report or Feature Request – it’s likely closest to Feature Request as I am requesting more information in the documentation. Please see the Proposed API section for my proposed resolution to this matter.

It doesn’t seem to be clear from the migration documentation how we are supposed to migrate usage of postLoaders to a Webpack Module Rule, specifically for the default template SFC block. In Vue Loader 14, we were able to assign a Webpack loader to the html property of postLoaders to obtain access to the emitted render function. The documentation does indicate how to process a new type of template language (pug), but not how to work with the render function that is emitted from a default template block.

In my case, I parse the emitted render function with an AST to extract parameters of specific function calls instead of statically parsing file contents using gettext. I have attempted to load the output from a template block in a number of different ways, referring to the Webpack documentation as well as the Vue Loader documentation. My loader is able to parse the script block but not the render function emitted from the template. Should we be targeting test with /\.html$/, or /\.vue$/? Do we need to use a resourceQuery? Do we need to use enforce: 'post'? Do we need to add a new language extension to every template block? There are a lot of variables in this that the standard Webpack documentation cannot address easily. I suppose this is one of the challenges of being coupled to Webpack – their documentation needs to be complemented.

I seem to have the most success with this rule:

    {
      resourceQuery: /^\?vue/,
      enforce: 'post',
      loader: resolve(__dirname, '../translations/webpackLoader'),
    },

Though it seems bare:

Starting new source: /[redacted]/modules/common/components/SampleComponent/index.vue
var render = function () {}
var staticRenderFns = []

export { render, staticRenderFns }

Component template for reference:

<template>
  <div>
    <h2>{{ label }}</h2>
    <p>This is dummy text</p>
    <p>{{ $t('Sample Component for !{name}', 'This is the context', { name }) }}</p>
  </div>
</template>

What does the proposed API look like?

If there is an obvious reason for not being able to parse the template block’s render function, I can create a PR to call it out in the docs right away. If there is not an obvious reason, I will spend some time creating a reproduction repository and file a bug report so we can investigate further and then add our findings (examples and explanations) to the docs.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
zgayjjfcommented, May 29, 2018

I didn’t realize it that postLoaders & preLoaders & loaders have been Deprecated… I think these options for loaders in V14 are better than it’s replacement in V15, for they were clear & consistent. While apis in V15 are not that clear, and break consistence——you have to add another option to bring back functionality like this #1328 , which makes configuration separated and breaks the consistence.

Yet, in spite of this, #1328 is a good way to make this right. I would be glad if it is merged. @daekano Thank you for your work.

0reactions
davidguilhermecommented, Feb 26, 2019

@yyx990803 I just opened a merge request with an alternative solution for this issue without bringing the postLoader option back.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How and When to Deprecate APIs - Oracle Help Center
Starting with J2SE 5.0, you deprecate a class, method, or field by using the @Deprecated annotation. Additionally, you can use the @deprecated Javadoc...
Read more >
deprecation — deprecation 2.0.6 documentation
deprecation is a library that enables automated deprecations. It offers the deprecated() decorator to wrap functions, providing proper warnings both in ...
Read more >
Deprecation guidelines - Public developer documentation
Deprecation is the process by which we refactor and clean up old code, getting rid of functions, classes, methods, files and resources that ......
Read more >
Deprecated settings - Puppet
About deprecations in this version · Web servers · Upcoming operating system deprecations · Language features · Extension points and APIs · Settings....
Read more >
The @deprecated Tag
As far as the compiler is concerned, the presence of the string "@deprecated" at the beginning of a documentation comment line (except for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found