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

Bug: everything fresh installed, yarn build doesnt work. #344

Closed
1 of 2 tasks
Depcos opened this issue Aug 11, 2023 · 8 comments · Fixed by #346
Closed
1 of 2 tasks

Bug: everything fresh installed, yarn build doesnt work. #344

Depcos opened this issue Aug 11, 2023 · 8 comments · Fixed by #346

Comments

@Depcos
Copy link

Depcos commented Aug 11, 2023

Which package(s) does this bug affect?

  • Create Plugin
  • Sign Plugin

Package versions

1.10.0

What happened?

So i freshly installed grafana in docker, everything is setup newly fresh and configs are set default (only plugin folder locaiton in grafana.ini is uncommented).
Creation of new plugin throught npx is okay i runned yarn install and everythings seems fine. But when i use yarn build / dev
Yarn newly throws this error.
I didnt touch any configuration of this plugin, everything is freshly installed.
(This plugin is named test, also tested other names, not the issue.)

warning package.json: "test" is also the name of a node core module
$ webpack -c ./.config/webpack/webpack.config.ts --env production
thread '' panicked at 'base_dir(./src) must be absolute. Please ensure that jsc.baseUrl is specified correctly.', /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_transforms_module-0.173.28/src/path.rs:104:13
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
assets by status 15.9 KiB [cached] 6 assets
./module.ts 39 bytes [built] [1 error]

ERROR in ./module.ts
Module build failed (from ../node_modules/swc-loader/src/index.js):
Error: failed to handle: base_dir(./src) must be absolute. Please ensure that jsc.baseUrl is specified correctly.

What you expected to happen

It should build like any other time.

How to reproduce it (as minimally and precisely as possible)

  1. In this environment...
    Docker grafana/grafana-enterprise:latest
  2. With this config...
    Default docker config
  3. Run yarn dev / yarn build / npm run dev
  4. See error...
    thread '' panicked at 'base_dir(./src) must be absolute. Please ensure that jsc.baseUrl is specified correctly.', /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/swc_ecma_transforms_module-0.173.28/src/path.rs:104:13
    note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
    assets by status 15.9 KiB [cached] 6 assets
    ./module.ts 39 bytes [built] [1 error]

ERROR in ./module.ts
Module build failed (from ../node_modules/swc-loader/src/index.js):
Error: failed to handle: base_dir(./src) must be absolute. Please ensure that jsc.baseUrl is specified correctly.

webpack 5.88.2 compiled with 1 error in 3826 ms
error Command failed with exit code 1.

Environment

System:
    OS: Linux 5.15 Alpine Linux
    CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
    Memory: 13.58 GB / 15.60 GB
    Container: Yes
    Shell: 1.35.0 - /bin/ash
  Binaries:
    Node: 18.17.0 - /usr/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.1.2 - /usr/bin/npm
  npmPackages:
    @grafana/data: 9.5.3 => 9.5.3
    @grafana/e2e: 9.5.3 => 9.5.3
    @grafana/e2e-selectors: 9.5.3 => 9.5.3
    @grafana/eslint-config: ^6.0.0 => 6.0.0
    @grafana/runtime: 9.5.3 => 9.5.3
    @grafana/tsconfig: ^1.2.0-rc1 => 1.2.0-rc1
    @grafana/ui: 9.5.3 => 9.5.3

Additional context

No response

@sympatheticmoose
Copy link
Contributor

Hi @Depcos - this is due to an issue in @swc/core release 1.3.76. We recommend downgrading to "@swc/core": "1.3.75", in package.json whilst we wait for the fix to be released - swc-project/swc-node#721

@ez-leka
Copy link

ez-leka commented Aug 14, 2023

in my package.json :

"@swc/core": "^1.3.62"

but I see exactly the same error. setting it to 1.3.75 - no effect. Please help

@academo
Copy link
Member

academo commented Aug 14, 2023

Hi @ez-leka keep in mind that you need to set "@swc/core": "1.3.75" (notice the removal of the ^ symbol) and run npm install later to see this issue fixed. Or you can do it all in a single command without having to modify any file yourself by running npm install -E @swc/core@1.3.75 (notice -E to install the exact version)

I recently released a version of create-plugin #346 that doesn't generate plugins with this error.

@academo academo closed this as completed Aug 14, 2023
@mikkancso
Copy link
Contributor

Hi!

whilst we wait for the fix to be released - swc-project/swc-node#721

I think that fix got released, but I still get the same error in our plugin with swc-core 1.3.90.

The swc maintainers recently updated the error message to

base_dir(src) must be absolute. Please ensure that jsc.baseUrl is specified correctly. This cannot be deduced by SWC itself because SWC is a transpiler and it does not try to resolve project details. In other works, SWC does not know which directory should be used as a base directory. It can be deduced if .swcrc is used, but if not, there are many candidates. e.g. the directory containing package.json, or the current working directory. Because of that, the caller (typically the developer of the JavaScript package) should specify it. If you see this error, please report an issue to the package author.

IMO that suggests that we should fix this in our webpack config. And I could fix it in our plugin by using baseUrl: path.resolve(__dirname, 'src'),.

@academo
Copy link
Member

academo commented Sep 28, 2023

@mikkancso you should be using the fixed version 1.3.75 which is the one defined in create-plugin. We have no control over the swc-core library. 1.3.90 is exactly the problematic version. Newer version might have a fix we haven't yet tested. can you try to upgrade to the latest version and see if this problem still happens?

@sympatheticmoose
Copy link
Contributor

Newer version might have a fix we haven't yet tested. can you try to upgrade to the latest version and see if this problem still happens?

@academo I think that's what @mikkancso has done

@mikkancso
Copy link
Contributor

@academo I have tried updating our plugin to 1.3.90, and I still get the same error, even though the bugfix in the swc project you have linked (swc-project/swc-node#721) is already merged and released in 1.3.90.

So I tried to fix this problem in our plugin, which you can check out here: https://github.com/grafana/cloud-onboarding/pull/5065 (yes, it does work)
But we decided against merging the fix in the plugin, as we believe this should be fixed in this repo, hence my PR in this repo: #424 . Could you please take a look at this PR?

@jordan-simonovski
Copy link

Hiya, this seems to have broken again with the release of "@swc/core": "1.3.95" which just got picked up in a Renovate PR.
I've implemented your fix in the PR you posted @mikkancso as a workaround for now 👍

mpatou added a commit to rockset/rockset-grafana-backend that referenced this issue Nov 6, 2023
mpatou added a commit to rockset/rockset-grafana-backend that referenced this issue Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging a pull request may close this issue.

6 participants