Skip to content

Adding a sample tsconfig file to the Encore documentation page #10521

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

Merged
merged 1 commit into from
Sep 26, 2019
Merged

Adding a sample tsconfig file to the Encore documentation page #10521

merged 1 commit into from
Sep 26, 2019

Conversation

iammichiel
Copy link
Contributor

No description provided.


.. code-block:: javascript

{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all block should be indented, isn't it?
what about Encore v0.21: is this still valid now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not yet had time to try this in the v0.21 version of Encore. I'll give it a try this evening.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So gave this a try on the 0.21.1 version of webpack-encore. It still complains with following message :

TS18002: The 'files' list in config file 'tsconfig.json' is empty.

Creating this file with this default content solved the problem. Plus most people, will customize their Typescript experience in the tsconfig file. Perhaps, this should even be fixed as a hook in the recipe of the new bundle.

"include": [
"./assets/js/**/*"
]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that Encore should configure for you? I don’t know typescript we’ll - what does the include do?

Copy link
Contributor Author

@iammichiel iammichiel Nov 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Well, Typescript (as far as I understand it) actually compiles your files to JS before webpack handles/bundles them. This options tells the compiler which files it should compile or not. By default, the compiler will not do anything at all as the files array is empty by default.

This simply tells the compiler, it should handle all files (having the .ts extension) in the assets/js folder.

@javiereguiluz
Copy link
Member

@tgalopin I know you know TypeScript very well ... could you please check if this proposal is correct? Thanks.

@javiereguiluz
Copy link
Member

Friendly ping to @Kocal and @Lyrkan to see if they can review this proposal. Thanks.

@Lyrkan
Copy link
Contributor

Lyrkan commented Sep 24, 2019

I don't think the include part is necessary, I just tested it on a really basic project with a tsconfig.json file that only contained {} and everything went fine:

$ cat tsconfig.json
{}

$ cat webpack.config.js
const Encore = require('@symfony/webpack-encore');

Encore
  .disableSingleRuntimeChunk()
  .setOutputPath('build/')
  .setPublicPath('/')
  .cleanupOutputBeforeBuild()
  .addEntry('main', './src/index.ts')
  .enableTypeScriptLoader()
;

module.exports = Encore.getWebpackConfig();

$ ./node_modules/.bin/encore dev
Running webpack ...

 DONE  Compiled successfully in 2095ms

 I  1 files written to build
Entrypoint main = main.js

Maybe it would be a better idea to directly add a link to TypeScript's documentation or to the Webpack's page about that topic?

@javiereguiluz javiereguiluz changed the base branch from master to 3.4 September 26, 2019 10:31
javiereguiluz added a commit that referenced this pull request Sep 26, 2019
…n page (iammichiel)

This PR was submitted for the master branch but it was merged into the 3.4 branch instead (closes #10521).

Discussion
----------

Adding a sample tsconfig file to the Encore documentation page

<!--

If your pull request fixes a BUG, use the oldest maintained branch that contains
the bug (see https://symfony.com/roadmap for the list of maintained branches).

If your pull request documents a NEW FEATURE, use the same Symfony branch where
the feature was introduced (and `master` for features of unreleased versions).

-->

Commits
-------

a4dd5e4 Adding a sample tsconfig file to the Encore documentation page
@javiereguiluz javiereguiluz merged commit a4dd5e4 into symfony:3.4 Sep 26, 2019
@javiereguiluz
Copy link
Member

@Lyrkan thanks a lot for reviewing this. I did what you asked and I added those links while merging. Thanks.

@iammichiel iammichiel deleted the patch-1 branch September 26, 2019 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants