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
{{ message }}
This repository was archived by the owner on Oct 9, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Oct 9, 2020. It is now read-only.
Builder fails silently once typescript is updated to 2.3.1+ #828
systemjs-builder: 0.16.9 (also tested and confirmed with 0.15.34)
typescript: 2.3.1+ (the issue does not exist with 2.3.0)
Issue
Yesterday i updated a project to typescript 2.4.2 (from 2.2.2) and my gulp build script started to fail silently. I've recreated a bare bones, minimal recreation of the issue here:
But i'm struggling to work out which bit of code actually gets called by loader.translate to determine where the actual failure occurs? I'll continue to see if i can debug it further to work out the source of the issue.
It looks like something has changed in typescript 2.3.1 which means that it's now detected as esm by the esmRegEx. So the if block on line 3544 gets run, which in turn causes the builder to silently fail.
I've forced the typescript source to not be detected as esm in my local version and everything works correctly and the build completes and outputs the file. But i'm afraid fixing the regex (or what's expected from it) is a bit beyond me.
Took a while to work out, but at least this made me smile ;)
good enough ES6 module detection regex - format detections not designed to be accurate, but to handle the 99% use case
Unfortunately setting the format to cjs (in either packages or meta) results in the following error:
{ Error on translate for main at file:///Users/blah/blah/project/src/main.ts
(SystemJS) ENOENT: no such file or directory, open '/Users/blah/blah/project/src/fs'
Error: ENOENT: no such file or directory, open '/Users/blah/blah/project/src/fs'
at Error (native)
Error loading /Users/blah/blah/project/src/fs as "fs" from /Users/blah/blah/project/node_modules/typescript/lib/typescript.js
Unable to load transpiler to transpile /Users/blah/blah/project/src/main.ts
originalErr:
{ Error: ENOENT: no such file or directory, open '/Users/blah/blah/project/src/fs'
at Error (native)
errno: -2,
code: 'ENOENT',
syscall: 'open',
path: '/Users/blah/blah/project/src/fs' } }
Activity
jamesbrobb commentedon Jul 29, 2017
I've tracked the issue down to here (as this verion of
systemjs-buildercurrently usessystemjs 0.19.47):https://github.com/systemjs/systemjs/blob/0.19.47/dist/system.src.js#L3544
It looks like something has changed in
typescript 2.3.1which means that it's now detected asesmby theesmRegEx. So theifblock on line 3544 gets run, which in turn causes the builder to silently fail.I've forced the typescript source to not be detected as
esmin my local version and everything works correctly and the build completes and outputs the file. But i'm afraid fixing the regex (or what's expected from it) is a bit beyond me.Took a while to work out, but at least this made me smile ;)
aluanhaddad commentedon Jul 29, 2017
Use
packageormetaconfiguration to targettypescriptand specifyformat: "cjs". The better solution though is to useplugin-typescript.jamesbrobb commentedon Jul 29, 2017
@aluanhaddad thanks for the quick response.
Unfortunately setting the format to
cjs(in eitherpackagesormeta) results in the following error:jamesbrobb commentedon Jul 29, 2017
Installing and configuring
plugin-typescriptfixed the issue, thanksaluanhaddad commentedon Jul 30, 2017
Yeah I forgot all of the other configuration that you need to add in addition to
format.plugin-typescripthelps handle that.I'm glad you got it working and I hope others find this discussion useful.