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
There are currently two issues I am facing with Rslib at this time.
Rsbuild is meant to be able to automatically find the entry point via src/index.ts and a load of other file extensions, according to the error I get. Issue is that when using Rslib without specifying a source.entry in the config, it cannot locate the entry src/index.ts file that I have.
This results in the following error:
error Failed to build.
error Could not find any entry module, please make sure that src/index.(ts|js|tsx|jsx|mjs|cjs) exists,
or customize entry through the source.entry configuration.
Entry config added to make it work:
source: {entry: {index: './src/index.ts',},},
Adding in the source.entry config resolves the above issue, then the second issue is that the ESM format output does not look correct. It only outputs *.d.mts file and no actual *.mjs files are created; this means that only type definitions exist and no actual code. Whereas the CJS format is correctly output *.js code files and also the *.d.ts type definition files.
To replicate these issues I have created a temp GitHub repository that can be cloned down and played with.
For the second issue regarding ESM format output being incorrect:
Clone the repository with git clone [email protected]:ShaneYu/rslib-esm-issue.git
Install the dependencies with pnpm install
Run a build with pnpm build
Now go and look at the output files under ./dist/esm you will notice that no *.mjs code files have been created, however the *.mts type definition files have been. The CJS output on the other hand, this has the expected code files and type definitions.
For the first issue regarding the entry point configuration:
Skip steps 1 and 2 if done previously.
Clone the repository with git clone [email protected]:ShaneYu/rslib-esm-issue.git
Install the dependencies with pnpm install
Edit the rslib.config.ts file to remove the source.entry config from both ESM and CJS lib configs
source: {entry: {index: './src/index.ts',},},
Run a build with pnpm build
Notice that despite having a src/index.ts file, it results in an error and states that the entry file cannot be found.
The text was updated successfully, but these errors were encountered:
ShaneYu
changed the title
[Bug]:
[Bug]: ESM format output is incorrect & auto detect entry file fails
Aug 30, 2024
Version
System: OS: Windows 11 10.0.22631 CPU: (32) x64 AMD Ryzen 9 7950X 16-Core Processor Memory: 4.11 GB / 31.21 GB Browsers: Edge: Chromium (127.0.2651.86) Internet Explorer: 11.0.22621.3527 npmPackages: @rslib/core: ^0.0.2 => 0.0.2
Details
There are currently two issues I am facing with Rslib at this time.
Rsbuild is meant to be able to automatically find the entry point via
src/index.ts
and a load of other file extensions, according to the error I get. Issue is that when using Rslib without specifying asource.entry
in the config, it cannot locate the entrysrc/index.ts
file that I have.This results in the following error:
Entry config added to make it work:
Adding in the
source.entry
config resolves the above issue, then the second issue is that the ESM format output does not look correct. It only outputs*.d.mts
file and no actual*.mjs
files are created; this means that only type definitions exist and no actual code. Whereas the CJS format is correctly output*.js
code files and also the*.d.ts
type definition files.Reproduce link
https://github.com/ShaneYu/rslib-esm-issue
Reproduce Steps
To replicate these issues I have created a temp GitHub repository that can be cloned down and played with.
For the second issue regarding ESM format output being incorrect:
git clone [email protected]:ShaneYu/rslib-esm-issue.git
pnpm install
pnpm build
Now go and look at the output files under
./dist/esm
you will notice that no*.mjs
code files have been created, however the*.mts
type definition files have been. The CJS output on the other hand, this has the expected code files and type definitions.For the first issue regarding the entry point configuration:
Skip steps 1 and 2 if done previously.
Clone the repository with
git clone [email protected]:ShaneYu/rslib-esm-issue.git
Install the dependencies with
pnpm install
Edit the
rslib.config.ts
file to remove thesource.entry
config from both ESM and CJS lib configsRun a build with
pnpm build
Notice that despite having a
src/index.ts
file, it results in an error and states that the entry file cannot be found.The text was updated successfully, but these errors were encountered: