Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
573 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 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...