Skip to content

ts-loader cannot accept *.js file as an entry point although allowJs parameter is set to true #163

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

Closed
tqmukas opened this issue Feb 29, 2016 · 16 comments
Labels

Comments

@tqmukas
Copy link

tqmukas commented Feb 29, 2016

If you specify any *.js file as an entry point inside the webpack configuration, ts-loader will throw an error (Module build failed: Error: Could not find file: ...).

...
entry: [
  './src/app.js'
],
...

I think this is ts-loader issue because TypeScript 1.8.0 and greater can transpile JavaScript files and import them. You have to set allowJs property to true to get this functionality working. Simply run the following code to test this.

tsc ./src/app.js --allowJs --outDir tsDist

For ts-loader, it seems that just an entry point must be always a *.ts file. Inside the entry module you actually are allowed to import and use both es6 and ts files.

@ocombe
Copy link

ocombe commented Mar 14, 2016

Yup I have the same problem :(

@jbrantly
Copy link
Member

Will try to address this in the next release.

@yazla
Copy link

yazla commented Mar 20, 2016

Btw, the js files included via ///<reference> seems also to be skipped by ts-loader.

@sirwolfgang
Copy link

What is the timeline for the next release?

@tqmukas
Copy link
Author

tqmukas commented Jul 1, 2016

Any news on this?

@dwasyluk
Copy link

Wondering if there are any updates or if anyone has found a workaround for this in the interim?

@jmalonzo
Copy link

@dwasyluk I believe this should've been fixed in 0.9.3. Can you please try that version?

@johnnyreilly
Copy link
Member

Yes this should be fine now I hope. Closing for now.

@whiterockerart
Copy link

I can't get it to work.
My tsconfig.json looks like this:
{ "compileOnSave": true, "compilerOptions": { "declaration": false, "diagnostics": true, "allowJs": true, "emitDecoratorMetadata": true, "experimentalDecorators": true, "module": "system", "moduleResolution": "classic", "noImplicitAny": true, "preserveConstEnums": true, "pretty": true, "removeComments": false, "rootDir": ".", "sourceMap": true, "sourceRoot": "/static/", "target": "es6", "outFile": "script_folder_one/scriptfilebundle.js" }, "files": [ "script_folder_one/nontypescript.js", "script_folder_one/scriptfile_01.ts", "script_folder_one/scriptfile_02.ts", "script_folder_two/eventmanager.ts" ] }

@johnnyreilly
Copy link
Member

You need to set the entryFilesIsJs loader option - see the docs

@whiterockerart
Copy link

whiterockerart commented Dec 6, 2016

We are using these compiler options: https://www.typescriptlang.org/docs/handbook/compiler-options.html

What you are describing isn't there. I'm using Visual Studio 2015 and it wont include the js files with the ts. But if I compile it with gulp-typescript, it works.

I see now that this thread is about ts-loader... I'm moving on.

@johnnyreilly
Copy link
Member

What you are describing isn't there

Make sure you are using 1.3.0

I see now that this thread is about ts-loader... I'm moving on.

Right... This is webpack - if that's not what you're after we can't help

@aluanhaddad
Copy link

@johnnyreilly since the ts section is, as you note in #425, disallowed by Webpack 2, is there currently a way to set this up? I am trying to convert a Webpack 1.14 application and would rather not switch to awesome-typescript-loader.

@aluanhaddad
Copy link

@johnnyreilly sorry, I just re-read the issue, 'ts-loader?allowJsEntry=true' does the trick. (face-palm).

@johnnyreilly
Copy link
Member

No worries!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants