Currently, I am utilizing systemJS for package management in my project. In order to configure systemJS, I have included the following lines in the configuration file:
{
map: { 'ng2-file-upload': 'node_modules/ng2-file-upload' },
packages: {
'ng2-file-upload': {
main: './ng2-file-upload/ng2-file-upload.js', // also tried with './ng2-file-upload.js'
defaultExtension: 'js'
},
}
}
To import ng2-file-upload, I use the syntax
import { FileDrop, FileUploader } from 'ng2-file-upload';
.
However, upon importing this module, my application crashes: although my TypeScript compiler appears to be functioning correctly (as indicated by other logs), the changes are no longer transpiled, rendering the application non-executable. There are no error logs directly related to ng2-file-upload (apart from numerous instances of Duplicate identifiers
).
Any suggestions on how to resolve this issue?
UPDATE: To troubleshoot, I relocated the package from node_modules
to a directory adjacent to my app (vendor
) and attempted to use a relative path for importing FileDrop
and FileUploader
. Unfortunately, systemJS failed to import them, generating the error message:
Error: SyntaxError: Unexpected token <(…)
UPDATE 2: Here are additional specifics regarding my setup.
My application is structured within a public
directory containing two sub-folders: src
and build
. TypeScript code is authored in src
(obviously) and the transpiled files are stored in build
. Presently, there is no bundling implemented, thus the hierarchy within build
mirrors that of src
.
Interestingly, during the transpilation process, TSC inexplicably creates a node_modules/ng2-file-upload
folder within build
. See below for the directory structure:
public
|-- build
| |-- core
| |-- modules
| |-- styles
| |-- node_modules
| | |-- ng2-file-upload
+-- src
|-- core
|-- modules
|-- styes
The reason behind TSC transpiling this package remains unknown. It is worth mentioning that node_modules
have been excluded in my tsconfig.ts
.