以下用法为:https://github.com/sveltejs/svelte-scroller
我知道错误了
UnhandledPromiseRejectionWarning: TypeError: _sveltejs_svelte_scroller__WEBPACK_IMPORTED_MODULE_1___default.a.data is not a function
at Object.App._render (webpack:///./app/App.html?:56:75)
at Object.App.render (webpack:///./app/App.html?:30:17)
at /Users/tim.clulow/Documents/_git/cssandstuff-sapper/node_modules/sapper/dist/src/middleware.ts:252:13
(node:52144) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:52144) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.有没有额外的webpack配置步骤,我需要做,以使苗条-滚轮工作在萨珀?
* UPDATE *,如果这对其他人有帮助,这里是我更新的webpack配置文件。它们被复制在下面。我对webpack很陌生,所以我真的很感激里奇的帮助,希望这能挽救别人的心痛。
client.config.js
const webpack = require('webpack');
const config = require('sapper/webpack/config.js');
const mode = process.env.NODE_ENV;
const isDev = mode === 'development';
module.exports = {
entry: config.client.entry(),
output: config.client.output(),
resolve: {
extensions: ['.js', '.json', '.html'],
mainFields: ['svelte', 'module', 'browser', 'main']
},
module: {
rules: [
{
test: /\.html$/,
use: {
loader: 'svelte-loader',
options: {
hydratable: true,
hotReload: true
}
}
}
]
},
mode,
plugins: [
isDev && new webpack.HotModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.browser': true,
'process.env.NODE_ENV': JSON.stringify(mode)
}),
].filter(Boolean),
devtool: isDev && 'inline-source-map'
};server.config.js:
const config = require('sapper/webpack/config.js');
const pkg = require('../package.json');
module.exports = {
entry: config.server.entry(),
output: config.server.output(),
target: 'node',
resolve: {
extensions: ['.js', '.json', '.html'],
mainFields: ['svelte', 'module', 'browser', 'main']
},
module: {
rules: [
{
test: /\.html$/,
use: {
loader: 'svelte-loader',
options: {
css: false,
generate: 'ssr'
}
}
}
]
},
mode: process.env.NODE_ENV,
performance: {
hints: false // it doesn't matter if server.js is large
}
};发布于 2018-05-14 14:44:05
是的,有。我们将很快更新模板,但与此同时,您可以按照本期中的步骤操作它
resolve.mainFields: ['svelte', 'module', 'browser', 'main']选项exclude选项,以便外部组件得到解析。externals选项,以便绑定外部组件(即由编译器处理),而不是在运行时导入(客户端)预编译版本。https://stackoverflow.com/questions/50330825
复制相似问题