neetjn / riot-routing

Lightweight client sided router for Riot.js.
MIT License
3 stars 0 forks source link

Can't resolve 'riot-routing' in 'root_dir/src' #7

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi!

So I am having an issue with 'riot-routing', but if i import anything from 'os' it'll work. Not sure if this is related to my webpack.config.js or riot-routing.

Below is the error:

ERROR in ./src/app.riot
Module not found: Error: Can't resolve 'riot-routing' in '/Users/user/folder/src'
 @ ./src/app.riot 2:0-44
 @ ./src/index.js

folder == root folder, where node_modules is located.

.
├── assets
├── index.html
├── package-lock.json
├── package.json
├── src
│   ├── app.riot 
│   ├── index.js
├── node_modules
└── webpack.config.js

app.riot:

<app>
  <router routes={routes} />

    <script>
      import { platform, release } from 'os' # works, added just to try it 
      import {LinkTo, Router} from 'riot-routing' # does not work!
      import Map from '@/map/map.riot' # @ = components folder

      export default {
        components: {
          Map
        },
      }
    </script>
</app>

webpack.config.js:

var config = {
  entry: './src/index.js',
  devtool: 'inline',
  resolve: {
    modules: ['node_modules'],
    extensions: ['.js'],
    alias: {
            '@': Path.resolve(paths.app, 'components'),
            '+': Path.resolve(paths.app, 'shared'),
            '#': Path.resolve(paths.app, 'utils')
    },
  },
    output: {
        path: paths.assets,
        publicPath: '/assets/',
        filename: 'app.js'
    },

  module: {
    rules: [
      {
        test: /\.riot$/,
        exclude: /node_modules/,
        use: [{
          loader: '@riotjs/webpack-loader',
          options: {
            hot: true, // set it to true if you are using hmr
            // add here all the other @riotjs/compiler options riot.js.org/compiler
            // template: 'pug' for example
          }
        }]
      }
    ]
  }
}

module.exports = config
neetjn commented 4 years ago

Thank you for your input! @itsmexi is this project available on github for me to pull down and check?

ghost commented 4 years ago

@neetjn I'll push an example tonight, eta: T+-5h. Been on a road trip. Also running macOS Mojave 10.14.6.

npm --version
6.13.7

node --version
v13.7.0
ghost commented 4 years ago

https://github.com/itsmexi/riot-routing-example

ERROR in ./src/app.riot Module not found: Error: Can't resolve 'riot-routing' in '/Users/robin/riot-routing-example/src' @ ./src/app.riot 2:0-45 @ ./src/index.js

neetjn commented 4 years ago

Bug resolved and addressed in https://github.com/neetjn/riot-routing/pull/8. Fix is available in the 0.0.2 release.

I apologize for the delayed response, it's been a crazy month.