-
-
Notifications
You must be signed in to change notification settings - Fork 61
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
Sourcemaps contain invalid references to node_modules/tslib when importHelpers: false
in tsconfig.json
#280
Comments
I also just ran across this problem since I don't want tslib included at all in my build. I found that rollup-plugin-typescript2 forces |
@ajlende - Yep, the docs that you linked to (https://github.com/ezolenko/rollup-plugin-typescript2#some-compiler-options-are-forced) look like at least part of the explanation of what's going on. Thanks for finding that info. I still don't understand why the sourcemap paths are broken though. Do you know?
Both the bili and the rollup version of the /*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
function useTsLib(a, b) {
// Uses the __spreadArrays function from tslib
return __spreadArrays([a], b);
}
export default useTsLib;
//# sourceMappingURL=index.module.js.map |
@justingrant I did an experiment by editing rollup-plugin-typescript2 to force var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
function useTsLib(a, b) {
// Uses the __spreadArrays function from tslib
return __spreadArrays([a], b);
}
export default useTsLib;
//# sourceMappingURL=index.module.js.map
Both of those differences lead me to believe that the build process with To confirm my suspicion, I updated your example to include another file that made use of the spread operator, and found that when I forced var __spreadArrays = undefined && undefined.__spreadArrays || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
s += arguments[i].length;
}
for (var r = Array(s), k = 0, i = 0; i < il; i++) {
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
r[k] = a[j];
}
}
return r;
};
function merge(a, b) {
// Uses the __spreadArrays function from tslib
return __spreadArrays(a, b);
}
var __spreadArrays$1 = undefined && undefined.__spreadArrays || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) {
s += arguments[i].length;
}
for (var r = Array(s), k = 0, i = 0; i < il; i++) {
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) {
r[k] = a[j];
}
}
return r;
};
function useTsLib(a, b) {
// Uses the __spreadArrays function from tslib
return merge(__spreadArrays$1([a], b), __spreadArrays$1(b, [a]));
}
export default useTsLib;
//# sourceMappingURL=index.module.js.map As far as why |
Bili is emitting a reference to
../node_modules/tslib/tslib.es6.js
in sourcemaps, even in projects whereimportHelpers
is false in tsconfig.json. Because tslib helpers are emitted directly into transpiled source, that file../node_modules/tslib/tslib.es6.js
won't exist on disk when the library is installed from the npm/yarn registry. This missing file causes warnings in webpack, parcel, and other tools that validate sourcemaps.I'm filing this issue here in bili (as opposed to rollup-plugin-typescript2, rollup, babel, etc.) because I was able to create a minimal rollup config (based on bili's rollup config) that doesn't exhibit this problem. So I'm assuming that something is happening in how bili is configuring rollup or its plugins that's triggering this problem.
Here's the problematic bili config:
And here's the working rollup config:
Repro
git clone https://github.com/justingrant/repro-tslib-sourcemap.git
cd repro-tslib-sourcemap
yarn
yarn build
- This will run both bili and rollup and produce two output folders:./dist-bili
and./dist-rollup
dist-rollup/index.module.js.map
. You'll see that tslib is not present in thesources
array of the sourcemap:dist-bili/index.module.js.map
Expected: sourcemap file doesn't contains tslib in its
sources
array.Actual: sourcemap file refers to a file that won't actually exist on disk when this library is packaged, because of
"importHelpers": false
in tsconfig.json. Here's the bad sourcemap:The text was updated successfully, but these errors were encountered: