Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
583 views
in Technique[技术] by (71.8m points)

svelte - How to build a module for consumption by sapper

I want to create an npm module that I can consume in a sapper app. The module exports a svelte component, and in that component there is a dependcy on @sapper/app e.g.:

  import { onMount } from 'svelte';
  import { stores } from '@sapper/app';

  const { page } = stores();

The module is written in typescript and I have added svelte and sapper as devDependencies. I am using rollup / typescript to build the module and create the type declarations.

However, since this module is to be consumed by sapper, which will also run typescript and rollup, I am confused as to whether or not I need to do this and therefore if sapper should just be importing the source files anyway?

So atm when I try to consume the (compiled) module I get:

Error: Cannot find module '@sapper/app'

Understandable, but I'm still unsure how to correctly structure this project for use - package.json and any necessary build steps, along with any specific steps to consume the module in sapper.

Help would be much appreciated.

question from:https://stackoverflow.com/questions/65922418/how-to-build-a-module-for-consumption-by-sapper

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...