Code Monkey home page Code Monkey logo

Comments (4)

icalvin102 avatar icalvin102 commented on June 20, 2024 1

@peterbabic this are the things I added to my config:

tsconfig.json

    "compilerOptions": {
        "lib": ["ES2019", "ES2017", "ES5", "ES6", "DOM"],
+       "baseUrl": ".",
+       "paths": {
+         "$src/*": ["src/*"],
+         "$lib/*": ["src/components/*"]
+      }
    },

rollup.config.js

+import alias from '@rollup/plugin-alias';
export default [
  {
    input: 'src/main.ts',
    output: {
      sourcemap: true,
      format: 'iife',
      name: 'app',
      file: 'public/build/bundle.js',
    },
    plugins: [
      ...otherPlugins,
+     alias({
+       resolve: ['.js', '.ts', '.svelte'],
+       entries: [
+         { find: '$src', replacement: './src' },
+         { find: '$lib', replacement: './src/components' },
+       ]
+     })
    ],
  },
]

It works in typescript and svelte files. However in svelte files autocompletion only works if the closing ' or " is present.

Example: import Foo from '$lib/<cursor> will not autocomplete correctly but import Foo from '$lib/<cursor>' will.

from coc-svelte.

davidroeca avatar davidroeca commented on June 20, 2024

🤔 this one's tough -- sorry for the late reply. One thing you could try is set up a tsconfig.json and use the typescript language server to achieve this. Though unfortunately you'd have to translate your alias config to TS and maintain that separately.

Relevant options include:

Potentially some others, too

from coc-svelte.

icalvin102 avatar icalvin102 commented on June 20, 2024

@davidroeca thanks. baseUrl and paths in tsconfig.json solved it.

from coc-svelte.

peterbabic avatar peterbabic commented on June 20, 2024

thanks. baseUrl and paths in tsconfig.json solved it.

@icalvin102 can you please show how did you do that?

from coc-svelte.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.