basarat/typescript-collections

Issues when packaging with babel+rollup

danwashusen opened this issue · 1 comments

Bounced up against an issue when trying to package up my project with babel+rollup (see https://github.com/microsoft/TypeScript-Babel-Starter).

$ npm run build-babel

> foobar@1.0.0 build-babel /mnt/c/Users/dan/Development/foobar
> npm run build-babel:types && npm run build-babel:js


> foobar@1.0.0 build-babel:types /mnt/c/Users/dan/Development/foobar
> tsc --emitDeclarationOnly


> foobar@1.0.0 build-babel:js /mnt/c/Users/dan/Development/foobar
> rollup -c


./src/index.ts → build/main/index.cjs.js, build/module/index.esm.js, build/browser/index.iife.js...
(!) Circular dependency: node_modules/typescript-logging/dist/commonjs/extension/ExtensionHelper.js -> node_modules/typescript-logging/dist/commonjs/log/category/CategoryService.js -> node_modules/typescript-logging/dist/commonjs/log/category/CategoryExtensionLoggerImpl.js -> node_modules/typescript-logging/di
st/commonjs/extension/ExtensionHelper.js
(!) Circular dependency: node_modules/typescript-logging/dist/commonjs/extension/ExtensionHelper.js -> node_modules/typescript-logging/dist/commonjs/log/category/CategoryService.js -> node_modules/typescript-logging/dist/commonjs/log/category/CategoryExtensionLoggerImpl.js ->  /mnt/c/Users/dan/Development/digi
talpigeon-transfers/node_modules/typescript-logging/dist/commonjs/extension/ExtensionHelper.js?commonjs-proxy -> node_modules/typescript-logging/dist/commonjs/extension/ExtensionHelper.js
(!) Circular dependency: node_modules/typescript-logging/dist/commonjs/extension/ExtensionHelper.js -> node_modules/typescript-logging/dist/commonjs/log/category/CategoryService.js -> node_modules/typescript-logging/dist/commonjs/extension/ExtensionHelper.js
(!) Circular dependency: node_modules/typescript-collections/dist/lib/umd.js -> node_modules/typescript-collections/dist/lib/umd.js
(!) Circular dependency: node_modules/typescript-collections/dist/lib/umd.js ->  /mnt/c/Users/dan/Development/foobar/node_modules/typescript-collections/dist/lib/umd.js?commonjs-proxy -> node_modules/typescript-collections/dist/lib/umd.js
[!] Error: Illegal reassignment to import 'commonjsHelpers'
node_modules/typescript-collections/dist/lib/umd.js (21:0)
19: })(function() {
20:         var define, module, exports;
21: require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];re
turn s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
    ^
22: "use strict";
23: var __extends = (this && this.__extends) || (function () {
Error: Illegal reassignment to import 'commonjsHelpers'

I was able to work-around the issue using the 'fix' suggested in rollup/rollup-plugin-commonjs#166 (comment) (e.g. resolve({ browser: true })).

The documentation for the browser flag suggests that its just something that you need to do. Maybe its not an issue with typescript-collections?

// some package.json files have a "browser" field which specifies
// alternative files to load for people bundling for the browser. If
// that's you, either use this option or add "browser" to the
// "mainfields" option, otherwise pkg.browser will be ignored