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

[typescript] external dependency error is not a function #943

Closed
cdalexndr opened this issue Jul 16, 2021 · 8 comments
Closed

[typescript] external dependency error is not a function #943

cdalexndr opened this issue Jul 16, 2021 · 8 comments

Comments

@cdalexndr
Copy link

cdalexndr commented Jul 16, 2021

  • Rollup Plugin Name: @rollup/plugin-typescript
  • Rollup Plugin Version: 8.2.3
  • Rollup Version: 2.53.2
  • Operating System (or Browser): Win10, Firefox
  • Node Version: v10.16.0
  • Link to reproduction (⚠️ read below): https://github.com/cdalexndr/rollup-plugins-943

Expected Behavior

No error.

Actual Behavior

Uncaught TypeError: fastdom__namespace.measure is not a function

Additional Information

Build produces a _interopNamespace function that breaks fastdom dependency:

	function _interopNamespace(e) {
		if (e && e.__esModule) return e;
		var n = Object.create(null);
		if (e) {
			Object.keys(e).forEach(function (k) {
				if (k !== 'default') {
					var d = Object.getOwnPropertyDescriptor(e, k);
					Object.defineProperty(n, k, d.get ? d : {
						enumerable: true,
						get: function () {
							return e[k];
						}
					});
				}
			});
		}
		n['default'] = e;
		return Object.freeze(n);
	}

       var fastdom__namespace = /*#__PURE__*/_interopNamespace(fastdom);
@cdalexndr
Copy link
Author

Not replicable with older versions:

  • @rollup/plugin-typescript 8.0.0
  • rollup 1.28.0

@cdalexndr
Copy link
Author

It seems to depend on rollup version. For example, using the same version of `@rollup/plugin-typescript: 5.0.1":

  • not reproductible with rollup@1.32.1
  • reproductible with latest version

@shellscape
Copy link
Collaborator

shellscape commented Jul 29, 2021

@cdalexndr can you try your reproduction with the latest version of rollup?

@lukastaegert not sure if this is related to rollup main, but it looks like it's annotated by rollup.

@cdalexndr
Copy link
Author

cdalexndr commented Aug 14, 2021

Same issue with latest versions:

    "@rollup/plugin-typescript": "^8.2.5",
    "rollup": "^2.56.2",

@cdalexndr
Copy link
Author

@cdalexndr can you try your reproduction with the latest version of rollup?

Added replication steps in sample repository readme. It's easy enough to test.

@cdalexndr
Copy link
Author

This issue prevents me from upgrading rollup, and I'm stuck with old bugs, such as watch mode ending on compile error.

cdalexndr added a commit to cdalexndr/fastdom that referenced this issue Sep 1, 2021
Prevents typescript from using interop, that can cause problems: rollup/plugins#943
@cdalexndr
Copy link
Author

It seems the that problem is fastdom using an old export syntax export = fastdom (also requiring import * as fastdom from "fastdom") that forces the generation of this interop namespace.

Changing fastdom to export default fastdom and using import fastdom from "fastdom" generates a simpler interop function that doesn't have this issue:
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

The same results are obtained using typescript option allowSyntheticDefaultImports: true with import fastdom from "fastdom".

Although the problem is resolved, this doesn't explain why the old version works.

@stale stale bot added the x⁷ ⋅ stale label Oct 31, 2021
@stale
Copy link

stale bot commented Nov 1, 2021

Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it.

@stale stale bot closed this as completed Nov 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants