-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build fails in fresh sveltejs/template-webpack setup #430
Comments
It works (compiles) when using |
For more information (defined in the template-webpack repo):
{
"name": "svelte-app",
"version": "1.0.0",
"devDependencies": {
"cross-env": "^7.0.3",
"css-loader": "^6.7.1",
"mini-css-extract-plugin": "^2.6.0",
"svelte": "^4.0.0",
"svelte-loader": "^3.1.9",
"webpack": "^5.70.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
},
"scripts": {
"build": "cross-env NODE_ENV=production webpack",
"dev": "webpack serve"
},
"dependencies": {
"svelte-jsoneditor": "^0.23.2"
}
}
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const path = require('path');
const mode = process.env.NODE_ENV || 'development';
const prod = mode === 'production';
module.exports = {
entry: {
'build/bundle': ['./src/main.js']
},
resolve: {
alias: {
svelte: path.resolve('node_modules', 'svelte/src/runtime')
},
extensions: ['.mjs', '.js', '.svelte'],
mainFields: ['svelte', 'browser', 'module', 'main'],
conditionNames: ['svelte', 'browser']
},
output: {
path: path.join(__dirname, '/public'),
filename: '[name].js',
chunkFilename: '[name].[id].js'
},
module: {
rules: [
{
test: /\.svelte$/,
use: {
loader: 'svelte-loader',
options: {
compilerOptions: {
dev: !prod
},
emitCss: prod,
hotReload: !prod
}
}
},
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader'
]
}
]
},
mode,
plugins: [
new MiniCssExtractPlugin({
filename: '[name].css'
})
],
devtool: prod ? false : 'source-map',
devServer: {
hot: true,
static: {
directory: path.join(__dirname, 'public'),
}
}
}; |
Thanks for reporting Julian. The error message suggests that your setup has an issue importing code from the Can you test whether the same error occurs when you use |
Thanks for looking at this? Indeed, using only
If you look at the full error log, there are many packets with such an error:
But online I found little about this. It may be something with ESM and CJS but I have little knowledge on how these work exactly. Do you have an idea on this? |
Okay, this could simply be a problem with svelte-loader for Webpack, but I think it will be easier for me to just move to Vite. I'll close this, thanks! |
Good to hear, thanks for sharing your solution! |
When using the (official) Svelte Webpack template, the build fails.
Steps to reproduce
npx degit sveltejs/template-webpack svelte-test
npm install svelte-jsoneditor
App.svelte
like so:npm run build
Expected outcome
No compilation errors
Actual outcome
Compilation fails with a long error message. It seems to be an issue with ESM.
A snippet from the error log (full below):
Full error log:
output.log
The text was updated successfully, but these errors were encountered: