You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When building with esbuild, @kintone/rest-api-client could not be imported.
I have prepared a sample project where you can tried two patterns of esbuild output format: commonJS and ESModule. sample project (This is the same as Reproduction below.)
I think the reason for not being able to import is as follows.
In ESModule, esbuild combines scripts into one file, so require(".") defined by import.meta.url will not working properly, which causes an error.
In CommonJS, import.meta.url will be blank, so you will get an error.
Therefore, I think it is necessary to change to a method that does not use import.meta.url.
node:internal/modules/cjs/loader:1224
throw new ERR_INVALID_ARG_VALUE('filename', filename, createRequireError);
^
TypeError [ERR_INVALID_ARG_VALUE]: The argument 'filename' must be a file URL object, file URL string, or absolute path
That is the unexpected behavior of esbuild and dual package, and we are still looking for a fundamental solution.
You can see the details of that behavior and workaround at https://zenn.dev/sosukesuzuki/articles/d8220ba2d869f0.
There are three workarounds.
Create esbuild plugin to load rest-api-client as CJS (described in the above article)
Bundle with another bundler, Rollup, webpack, etc.
Summary
When building with esbuild,
@kintone/rest-api-client
could not be imported.I have prepared a sample project where you can tried two patterns of esbuild output format: commonJS and ESModule.
sample project (This is the same as Reproduction below.)
I think the reason for not being able to import is as follows.
import.meta.url
will not working properly, which causes an error.import.meta.url
will be blank, so you will get an error.Therefore, I think it is necessary to change to a method that does not use
import.meta.url
.Target Package
@kintone/rest-api-client
Target Version
5.0.8
Reproduction
This is sample project for minimum reproduction.
https://github.com/future-ota3727/esbuild-import-meta
You can try 2 patterns for the esbuild output format.
Expected Behavior
Import succeeded without any errors.
Actual Behavior
In ESModules, I got error:
In CommonJS, I got error:
Environment
System:
OS: Linux 5.10 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
Memory: 24.27 GB / 24.84 GB
Container: Yes
Shell: 5.1.16 - /bin/bash
Binaries:
Node: 18.18.0 - ~/.nvm/versions/node/v18.18.0/bin/node
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.0/bin/npm
npmPackages:
@kintone/rest-api-client: 5.0.8 => 5.0.8
esbuild: 0.20.0 => 0.20.0
The text was updated successfully, but these errors were encountered: