Gomah / nuxt-stencil

Easy Stencil.js component library integration with Nuxt.js.
MIT License
21 stars 1 forks source link

Lib or component is not found if use nodejs path module on Windows #12

Open patrickalima98 opened 4 years ago

patrickalima98 commented 4 years ago

Hello @Gomah, after trying include a stencil lib using path.resolve(), the nuxt-stencil can't find the module.

The problem is because the Windows use \ and not /, so your plugin.ts, is generate this file:

image

With this, I get this response:

image

But, if I replace \ to /, works fine.

I have an idea how to fix it, if you agree, I can make a PR :)

Steps for to reproduce:

1- Add any stencil lib or component in the static folder. 2- Make the configuration using the path module. 3- run npm run dev 4- check the terminal and stencil.js in .nuxt/stencil.js.

My nuxt.config.js:

// const locales = require('./lang');
import path from 'path';
import locales from './lang/index';

export default {
  mode: 'spa',
  /*
  ** Headers of the page
  */
  head: {
    title: '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' },
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
    ],
  },
  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },
  /*
  ** Global CSS
  */
  css: [
  ],
  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
  ],
  /*
  ** Nuxt.js dev-modules
  */
  buildModules: ['@nuxt/typescript-build'],
  /*
  ** Nuxt.js modules
  */
  modules: [
    ['nuxt-i18n', {
      locales,
      lazy: true,
      langDir: 'lang/',
      strategy: 'prefix',
      defaultLocale: 'pt-br',
    }],
    'nuxt-stencil',
  ],
  /*
  ** Build configuration
  */
  build: {
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
    },
    babel: {
      plugins: [
        ['@babel/plugin-proposal-decorators', { legacy: true }],
        ['@babel/plugin-proposal-class-properties', { loose: true }],
      ],
    },
  },
  stencil: {
    /**
     * Required options
     */

    // Your library name, or the path to its root folder.
    lib: 'nuiverse-ui',

    // By default, it takes the lib name. e.g: bulmil/dist/hydrate
    hydratePath: path.join(__dirname, './static/nuiverse-ui/dist/hydrate'),

    // By default, it takes the lib name. e.g: bulmil/dist/loader
    loaderPath: path.join(__dirname, './static/nuiverse-ui/dist/loader'),

    // The prefix to whitelist
    prefix: 'nv-',
  },
};

My environment:

OS: Windows 10 x64 Version 1903 Node: 10.16.3 NPM: 6.9.0 Nuxt: 2.0.0 nuxt-stencil: 0.1.1

Gomah commented 4 years ago

I can't reproduce it as I'm not on Windows, so feel free to make a PR :)

patrickalima98 commented 3 years ago

Hi @Gomah, how are you? I opened the PR to fix this issue, Can you see this please? :)

PR: https://github.com/Gomah/nuxt-stencil/pull/66

Thank you