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

Plugin crashes when an other plugin generates a deferred asset #162

Closed
Septh opened this issue Dec 15, 2021 · 1 comment
Closed

Plugin crashes when an other plugin generates a deferred asset #162

Septh opened this issue Dec 15, 2021 · 1 comment

Comments

@Septh
Copy link

Septh commented Dec 15, 2021

  • Version: 2.0.4
  • Rollup Version: 2.61.1
  • Operating System and version (if applicable):
  • Node Version (if applicable):
  • Does it work with tsc (if applicable):

According to Rollup's documentation on plugin development, when calling this.emitFile():

It is possible to defer setting the source via this.setAssetSource(referenceId, source) to a later time

However, when doing so, rollup-plugin-ts crashes with:

[!] (plugin Typescript) TypeError: The "path" argument must be of type string. Received undefined
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
    at validateString (internal/validators.js:120:11)
    at Object.normalize (path.js:1005:5)
    at ensurePosixReturnValue (/home/runner/rollup-plugin-ts-repro/node_modules/crosspath/dist/cjs/index.js:45:64)
    at Object.normalize (/home/runner/rollup-plugin-ts-repro/node_modules/crosspath/dist/cjs/index.js:93:20)
    at Object.generateBundle (/home/runner/rollup-plugin-ts-repro/node_modules/rollup-plugin-ts/dist/cjs/index.js:8528:69)
    at /home/runner/rollup-plugin-ts-repro/node_modules/rollup/dist/shared/rollup.js:22681:25

Reproduction

I have made a repl here : https://replit.com/@Septh/rollup-plugin-ts-repro#rollup.config.js

Two things to note:

  1. if you swap the order of the plugins, the build completes because then myPlugin has a chance of setting the source of the asset before it gets to rollup-plugin-ts.
  2. if you use name instead of fileName in this.emitFile(), then the build completes whatever the order of the plugins.

Expected Behavior

No crash.

Actual Behavior

Crash.

@wessberg
Copy link
Owner

wessberg commented Jan 3, 2022

Hey there. Thanks for reporting it. A test case has been written, and this has been fixed in v2.0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants