[BUG] Creating an empty `snowpack.config.js` causes other snowpack commands to expect a missing module
See original GitHub issueBug Report Quick Checklist
- I am on the latest version of Snowpack (3.5.6) & all plugins.
- I use package manager npm v6.14.13
- I run Snowpack on OSX 10.13.6
- I run Snowpack on Node.js v14.7.0
Describe the bug
snowpack dev
works perfectly for me locally. with no snowpack.config.js
. I have installed @snowpack/plugin-webpack ^2.3.1
and am now trying to build/bundle my project.
- Whenever I create an empty
snowpack.config.js
(invoked viasnowpack init
),snowpack dev
breaks with a ReferenceError to a missing module it expects. snowpack build
also breaks in the same way.- If I delete
snowpack.config.js
and change nothing else,snowpack dev
works perfectly again. snowpack build
also works without asnowpack.config.js
, the downside being that I can’t configure the build.
The same error trace is invariant to re-evaluating my shell, restarting terminal, restarting my computer, or nuking my node modules and trying again.
> snowpack dev
(node:20522) UnhandledPromiseRejectionWarning: ReferenceError: module is not defined
at file:///<my_repo_dir>/snowpack.config.js:5:1
at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
at async Loader.import (internal/modules/esm/loader.js:177:24)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:20522) 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(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:20522) [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.
To Reproduce
Set up node env with npm init --yes
in my project folder, set up project dependencies.
The only non-snowpack dependency in my project is p5 ^1.3.1
. I have tried to make snowpack work both with my code set up to expect P5 as an old-school import (<script src="..."></script>
to a local file) or with ES6 imports (import p5 from 'p5';
), and it doesn’t seem to make a difference either way.
I followed the setup instructions at Snowpack.dev Quick Start.
npm install --save-dev snowpack
- Aliased the snowpack runner commands:
// within package.json
"scripts": {
"start": "snowpack dev",
"init": "snowpack init",
"build": "snowpack build"
}
- Check that dev server works.
npm run start
I then followed the setup instructions at Snowpack.dev Build Pipeline.
npm install --save-dev @snowpack/plugin-webpack
- Added plugin information to
package.json
.
// within package.json
{
"plugins": [["@snowpack/plugin-webpack"]]
}
- Check that
npm run start
andnpm run build
work. npm run init
to create a snowpack config file.- Received the error shown in the previous section.
Expected behavior
I expected snowpack to continue working as before upon creation of an empty config file.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:6
Top GitHub Comments
Hi @1bsilver are you still working on this? I would like to jump in if you’ve not gotten the chance to pick it up yet?
Okay @dhrubesh. Go ahead.