bundle size is more than 1MB
See original GitHub issueDo you want to request a feature or report a bug? bug
What is the current behaviour?
when I run preact build --no-prerender --service-worker=false --template src/template.html
then my bundle file is including __tests__/*.js
folders, as well as other partial exports files and unused files from my application and itβs creating bundle.js size 1.2mb(un gzipped )
If the current behaviour is a bug, please provide the steps to reproduce.
What is the expected behaviour?
Ideally, my bundle.js should be adding only for imported files into component/app.js
If this is a feature request, what is motivation or use case for changing the behaviour? No Please mention other relevant information. my package.json files look like this:
...
"scripts": {
"build": "sh -ac '. ./.env.${PREACT_APP_ENV}; preact build --no-prerender --service-worker=false --template src/template.html'",
"build:production": "PREACT_APP_ENV=production npm run build",
"test": "NODE_ENV=test jest --no-cache --coverage",
"test:watch": "NODE_ENV=test jest --verbose --watch",
},
...
and my preact.config.js looks like this:
import envVars from 'preact-cli-plugin-env-vars';
const WorkboxPlugin = require('workbox-webpack-plugin');
export default (config, env, helpers) => {
process.env.PREACT_APP_ENV_NAME = process.env.PREACT_APP_ENV_NAME ? process.env.PREACT_APP_ENV_NAME : 'dev';
envVars(config, env, helpers);
config.plugins.push(
new WorkboxPlugin.InjectManifest({
swSrc: './service-worker.js',
swDest: './service-worker.js',
include: [/\.png$/, /\.ico$/],
})
);
config.resolve.alias = Object.assign({}, config.resolve.alias, {
react: 'preact/compat',
'react-dom': 'preact/compat'
});
return config;
};
dependencies of Preact:
"preact": "^10.0.5",
"preact-async-route": "^2.2.1",
"preact-router": "^3.1.0",
Please paste the results of preact info
here.
ββ
ββββββββββ
βββββββββββββββββ
βββββββββ ββββββββββ
βββββββ ββββββββ βββ
βββββ βββ βββ ββββ preact-cli 2.2.1
βββ ββββββββ βββ βββ
ββββββββββββββββββββ
ββββββββββββββββ
βββββββββ
ββ
For help with a specific command, enter:
preact help [command]
Commands:
create [template] [dest] Create a new application.
build [src] [dest] Create a production build in build/
watch [src] Start a development live-reload server.
serve [dir] Start an HTTP2 static fileserver.
list List all official templates
Options:
-h, --help Show help [boolean]
Unknown argument: info
@prateekbh, @ForsakenHarmony can you guide me here if something Iβm doing wrong here
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
Solution: Any file/folder is part of
src/routes
will be added in themain.js
bundle files. just createdroutes/__tests__
and migrated test file here then I got correct and expected bundle size@ajay28kumar a few questions to try to narrow things down:
require.context
anywhere?require("foo" + x + "bar")
)preact.config.js
?npm ls --depth 0
Preact CLI on its own will never bundle files that arenβt specifically imported. We donβt even auto-load routes from the filesystem, everything gets into the bundle exclusively through import and require.