<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ribal</title>
    <description>The latest articles on DEV Community by Ribal (@itsribs).</description>
    <link>https://dev.to/itsribs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F784560%2F9677053c-dac6-4c81-b517-a1cebcedf423.jpeg</url>
      <title>DEV Community: Ribal</title>
      <link>https://dev.to/itsribs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/itsribs"/>
    <language>en</language>
    <item>
      <title>How (Not) to Integrate i18n Support with Vuelidate in Vue 3</title>
      <dc:creator>Ribal</dc:creator>
      <pubDate>Mon, 07 Mar 2022 13:55:56 +0000</pubDate>
      <link>https://dev.to/itsribs/how-not-to-integrate-i18n-support-with-vuelidate-in-vue-3-3ode</link>
      <guid>https://dev.to/itsribs/how-not-to-integrate-i18n-support-with-vuelidate-in-vue-3-3ode</guid>
      <description>&lt;h3&gt;
  
  
  Diary of a Broken Dev: Entry 2
&lt;/h3&gt;

&lt;p&gt;Hello again, it's another Monday, and I have ~6 unlogged hours of work over the weekend because I could not resolve any of the Typescript errors stopping me from committing my branch and pushing it to the company repo.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not all Documentation is Created Equal
&lt;/h3&gt;

&lt;p&gt;Take a gander at &lt;a href="https://vuelidate-next.netlify.app/advanced_usage.html#i18n-support"&gt;this section&lt;/a&gt; of Vuelidate's documentation. If this makes sense to you, you're either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A developer with a good head on his shoulders, well-adjusted to the rigors of the field, and have an understanding of the technologies being used&lt;/li&gt;
&lt;li&gt;Not using Typescript&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you're using Typescript in your project and are trying to follow the documentation, good luck.&lt;/p&gt;

&lt;h3&gt;
  
  
  Down the Rabbit Hole we Go
&lt;/h3&gt;

&lt;p&gt;Please, do yourself a favor, before even thinking of reading the rest of this buffoonery, download &lt;a href="https://www.npmjs.com/package/@types/vuelidate"&gt;Vuelidate's ts-types&lt;/a&gt; from npm/yarn/suicide weapon of choice. Next, please just paste this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;messagePath&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;$validator&lt;/span&gt; &lt;span class="p"&gt;}:&lt;/span&gt; &lt;span class="nx"&gt;MessageProps&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s2"&gt;`whereverYourMessagesAre.&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;$validator&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While we're on the topic, please also copypasta the following at the very top of the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;MessageProps&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@vuelidate/validators&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why yes, I did just save you hours of labor, how could you tell?&lt;/p&gt;

&lt;h3&gt;
  
  
  Gotcha!
&lt;/h3&gt;

&lt;p&gt;You thought you were home free? So did I my friend, but what bamboozles one can bamboozle them all. You're gonna also need to create a nice little function in the index.ts file of your i18n folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;_i18n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;useI18n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;  &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;_i18n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;setupI18n&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;_i18n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;setupI18n&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;de&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;legacy&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="p"&gt;}):&lt;/span&gt; &lt;span class="nx"&gt;I18n&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_i18n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;_i18n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nx"&gt;_i18n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createI18n&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;setI18nLanguage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_i18n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;_i18n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;setI18nLanguage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i18n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;I18n&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nx"&gt;i18n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;loadLocaleMessages&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;i18n&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;I18n&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;messages&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
&lt;span class="cm"&gt;/* webpackChunkName: "locale-[request]" */&lt;/span&gt; &lt;span class="s2"&gt;`@/locales/&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;/index.ts`&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;i18n&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;global&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;setLocaleMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;locale&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;messages&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;default&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You're gonna wanna import that sweet sweet useI18n function, and use it to initialize an i18n variable in lieu of the one in Vuelidate's documentation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Takeaways and Lessons Learned
&lt;/h3&gt;

&lt;p&gt;Management has not seen a single commit since Thursday last week, which probably means they don't even need to see this devlog to fire me.&lt;/p&gt;

</description>
      <category>vue</category>
      <category>webdev</category>
      <category>vuelidate</category>
      <category>i18n</category>
    </item>
    <item>
      <title>How (Not) to Bundle a Component Library in Vue 3</title>
      <dc:creator>Ribal</dc:creator>
      <pubDate>Fri, 11 Feb 2022 14:01:28 +0000</pubDate>
      <link>https://dev.to/itsribs/how-not-to-bundle-a-component-library-in-vue-3-2p3c</link>
      <guid>https://dev.to/itsribs/how-not-to-bundle-a-component-library-in-vue-3-2p3c</guid>
      <description>&lt;h2&gt;
  
  
  Diary of a Broken Dev: Entry #1
&lt;/h2&gt;

&lt;p&gt;Hello, I refuse to introduce myself any further even though this is my first official post. The topic at hand today is to make sense of the last 3 days at my current job, and (hopefully) justifying why they pay me.&lt;/p&gt;

&lt;h3&gt;
  
  
  isCE: Not a Boolean Failing to Adhere to Semantic Variable Declaration
&lt;/h3&gt;

&lt;p&gt;Narratives are unimportant, what matters is that our custom component library was refusing to play nice. After building it and attempting to import it into any other project, regardless of configuration, we were met with the following error:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Uncaught TypeError: Cannot read properties of null (reading 'isCE')&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well isn't that grand? Googling for possible &lt;a href="https://github.com/vuejs/core/issues/4344"&gt;leads&lt;/a&gt; led nowhere fast. We were pretty much on our own in the vast open (shit) sea without a mast.&lt;/p&gt;

&lt;h3&gt;
  
  
  Not All Build Configurations are Created Equal
&lt;/h3&gt;

&lt;p&gt;Poring over the &lt;a href="https://cli.vuejs.org/guide/build-targets.html#app"&gt;Vue CLI&lt;/a&gt; docs led me to an ambiguously worded statement.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note on Vue Dependency&lt;/p&gt;

&lt;p&gt;In lib mode, Vue is externalized. This means the bundle will not bundle Vue even if your code imports Vue. If the lib is used via a bundler, it will attempt to load Vue as a dependency through the bundler; otherwise, it falls back to a global Vue variable.&lt;/p&gt;

&lt;p&gt;To avoid this behavior provide --inline-vue flag to build command.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Like any able-minded individual, I did what was only natural: contact my brother who is a linguist and has a background in programming. He confirmed that the statement was, in fact, worded ambiguously. Being that he is a non-prescriptivist, he went on to explain the importance of context and the democratization of language. This led me much closer to a solution than the previous 48 hours did.&lt;/p&gt;

&lt;h3&gt;
  
  
  If it Makes Sense But Doesn't Work, You're a Programmer
&lt;/h3&gt;

&lt;p&gt;I actually just ended up removing the &lt;code&gt;--inline-vue&lt;/code&gt; flag, created a vue.config.js file and added the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;configureWebpack: {
  output: {
    libraryExport: "default",
  },
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What does this do? Fuck if I know. At this point, I couldn't care less. After that, in the host project, I created another vue.config.js file and code-bae'd some:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  chainWebpack(config) {
    config.resolve.alias.set("vue", 
    path.resolve("./node_modules/vue"));
  },
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fortunately, I actually know what this does. This is something-something prevents double Vue import.&lt;/p&gt;

&lt;h2&gt;
  
  
  Takeaways and Lessons Learned
&lt;/h2&gt;

&lt;p&gt;Hope management doesn't see this devlog and fire me, such that I might save enough money to buy a farm and stop doing this to myself for a living.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
