Skip to content
This repository has been archived by the owner on Dec 1, 2019. It is now read-only.

Emit declaration files into the correct location based on WebPack's context #136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bryanforbes
Copy link

Given the following project structure:

project/
    src/
        thing1.ts
        thing2.ts

and the following WebPack configuration:

module.exports = {
    context: 'src',
    entry: {
        thing1: 'thing1.ts',
        thing2: 'thing2.ts'
    },
    output: {
        path: path.join(__dirname, 'dist'),
        filename: '[name].js',
        libraryTarget: 'umd'
    },
    resolve: {
        extensions: [ '', '.ts', '.js' ],
        root: 'src'
    },
    module: {
        loaders: [
            {
                test: /\.ts$/,
                loader: 'awesome-typescript-loader',
                query: {
                    declaration: true
                }
            }
        ]
    }
};

The following directory structure is created:

project/
    dist/
        src/
            thing1.d.ts
            thing2.d.ts
        thing1.js
        thing2.js

This pull request updates the declaration file destination calculation to use WebPack's loaderUtils to determine where to emit the declaration file. This pull request does not cover "elided" declaration files which will still output with the incorrect path.

@s-panferov
Copy link
Owner

@bryanforbes thanks for the PR! I need to make some research to find the best way to store declaration files. I'll try not to prolong this.

@ghost ghost mentioned this pull request Sep 30, 2016
gonzofish added a commit to gonzofish/angular-librarian that referenced this pull request Mar 1, 2017
There is [an outstanding awesome-typescript-loader issue](s-panferov/awesome-typescript-loader#193) and [an unmerged PR](s-panferov/awesome-typescript-loader#136) which talk to this issue.

Seems that, for the .d.ts files, ATL doesn't understand the Webpack context properly when outputting files.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants