Skip to content
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

can't use slic-watch-core without a bundler #115

Closed
JamesKyburz opened this issue Jan 20, 2024 · 1 comment · Fixed by #116
Closed

can't use slic-watch-core without a bundler #115

JamesKyburz opened this issue Jan 20, 2024 · 1 comment · Fixed by #116
Labels
bug Something isn't working

Comments

@JamesKyburz
Copy link
Contributor

JamesKyburz commented Jan 20, 2024

Describe the bug

I was going to start writing a sam plugin for this for sam-expand however found that slic-watch-core couldn't be imported or required. This is because the file is .js, the module isn't type module, and there aren't any package.json exports.

slic-watch-core doesn't work with require or import.

To Reproduce
Steps to reproduce the behavior:

~ ᐅ nvm use 20
Now using node v20.11.0 (npm v10.2.3)
~ ᐅ mkdir -p /tmp/slic-test
~ ᐅ ^mkdir -p^cd
~cd /tmp/slic-test
/tmp/slic-test ᐅ npm init -y &>/dev/null && npm i slic-watch-core &>/dev/null
/tmp/slic-test ᐅ node
Welcome to Node.js v20.11.0.
Type ".help" for more information.
> require('slic-watch-core')
/private/tmp/slic-test/node_modules/slic-watch-core/dist/index.js:27
import { get, merge } from "lodash";
^^^^^^

Uncaught:
SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import:
> import('slic-watch-core')
Promise {
  <pending>,
  [Symbol(async_id_symbol)]: 141,
  [Symbol(trigger_async_id_symbol)]: 6
}
> (node:58578) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/private/tmp/slic-test/node_modules/slic-watch-core/dist/index.js:27
import { get, merge } from "lodash";
^^^^^^

Uncaught:
SyntaxError: Cannot use import statement inside the Node.js REPL, alternatively use dynamic import:

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots, Input Files and Logs
If applicable, add screenshots, CloudFormation templates, serverless configuration and/or logs to help explain your problem.

Environment:

  • OS: macOS
  • Node.js Version: v20.11.0
  • NPM version: v10.2.3
  • Serverless Framework Version: n/a

Additional context
It's been broken since version 3.0.0, v2 worked with both require and import.

@JamesKyburz JamesKyburz added the bug Something isn't working label Jan 20, 2024
@eoinsha
Copy link
Contributor

eoinsha commented Jan 22, 2024

Thanks for this @JamesKyburz. It makes sense from a first look. We are planning on a separate, library version of slic-watch-core so this is good to know about. We are just going to test all permutations of the PR before merge and release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants