Skip to content

Fail to locate @import file "~@pkg/style.styl" in node_modules #49

@KarlBao

Description

@KarlBao

Expected behavior

Expect to locate the .styl file from node_modules with ~ (which works well when bundled with Webpack)

<style lang="stylus" scoped>
@import '~@my-pkg/style.styl'
</style>

Actual behavior

Get the error:

failed to locate @import file ~@my-pkg/style.styl
    at Evaluator.visitImport (C:\Users\dev\node_modules\stylus\lib\visitor\evaluator.js:915:21)
    ...
    ...
    ...

However, when I import the .styl file with relative path:

<style lang="stylus">
@import '../node_modules/@my-pkg/style.styl'
</style>

It works fine.

Steps to reproduce the behavior

My rollup config:

import vue from 'rollup-plugin-vue'
import typescript from 'rollup-plugin-typescript2'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import json from 'rollup-plugin-json'

export default {
  input: 'src/index.vue',
  output: {
    format: 'esm',
    file: 'dist/bundle.esm.js'
  },
  plugins: [
    nodeResolve({
      jsnext: true,
      main: true
    }),
    commonjs(),
    json(),
    typescript({
      rollupCommonJSResolveHack: true,
      useTsconfigDeclarationDir: true
    }),
    vue()
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions