Svelte + Rollup 在 Yarn 工作区中找不到 Typescript 文件
Svelte + Rollup can't find Typescript file in Yarn workspaces
如何使“frontend”文件夹中的汇总包含位于“common”文件夹中的文件?
- root
| - package.json
| - frontend
| - index.svelte
| - rollup.config.js
| - package.json
| - backend
| - index.ts
| - package.json
| - common
| - status.ts
| - package.json
root/package.json
{
"private": true,
"workspaces": [
"backend",
"common",
"frontend"
]
}
root/frontend/package.json
{
"name": "my-project-frontend",
...
"dependencies": {
...
"my-project-common": "^0.1.3",
}
}
root/common/package.json
{
"name": "my-project-common",
"version": "0.1.4"
}
root/common/status.ts
export const StatusLabel = {
CREATED: 'CREATED',
QUEUED: 'QUEUED',
RUNNING: 'RUNNING',
FINNISHED: 'FINNISHED'
}
root/frontend/index.苗条
import { StatusLabel } from "my-project-common/status";
这是returns构建时的错误信息
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
my-project-common/status (imported by index.svelte)
错误中的 link 会将您带到一个页面,上面写着:
Rollup will only resolve relative module IDs by default
所以我会像这样使导入相对:
import { StatusLabel } from '../common/status'
如示例文档所示:https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
/ input
// src/main.js (entry point)
import x from '../external.js';
import './nested/nested.js';
console.log(x);
Link相对来说
import { StatusLabel } from './common/status'
如何使“frontend”文件夹中的汇总包含位于“common”文件夹中的文件?
- root
| - package.json
| - frontend
| - index.svelte
| - rollup.config.js
| - package.json
| - backend
| - index.ts
| - package.json
| - common
| - status.ts
| - package.json
root/package.json
{
"private": true,
"workspaces": [
"backend",
"common",
"frontend"
]
}
root/frontend/package.json
{
"name": "my-project-frontend",
...
"dependencies": {
...
"my-project-common": "^0.1.3",
}
}
root/common/package.json
{
"name": "my-project-common",
"version": "0.1.4"
}
root/common/status.ts
export const StatusLabel = {
CREATED: 'CREATED',
QUEUED: 'QUEUED',
RUNNING: 'RUNNING',
FINNISHED: 'FINNISHED'
}
root/frontend/index.苗条
import { StatusLabel } from "my-project-common/status";
这是returns构建时的错误信息
(!) Unresolved dependencies
https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
my-project-common/status (imported by index.svelte)
错误中的 link 会将您带到一个页面,上面写着:
Rollup will only resolve relative module IDs by default
所以我会像这样使导入相对:
import { StatusLabel } from '../common/status'
如示例文档所示:https://rollupjs.org/guide/en/#warning-treating-module-as-external-dependency
/ input
// src/main.js (entry point)
import x from '../external.js';
import './nested/nested.js';
console.log(x);
Link相对来说
import { StatusLabel } from './common/status'