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

customTranformersPath #423

Closed
wants to merge 5 commits into from
Closed

Conversation

goloveychuk
Copy link
Contributor

Since with CheckerPlugin checker starting in forked process, it's impossible to pass function as an argument.
The solution could be to pass customTransformer as a module path.

@goloveychuk
Copy link
Contributor Author

goloveychuk commented Jun 30, 2017

actually, we can reproduce webpack2 behaviour

/webpack
     /config.js
     /mycustom-loader.js

in config.js

const config = {
   use: [
         { loader: 'mycustom-loader', options: {} }
   ]
}

So webpack resolves loaders relatively for webpack root.
Same could be done for atl

@goloveychuk
Copy link
Contributor Author

actually, easiest way to go:

use: [
      {
        loader: 'awesome-typescript-loader',
        options: {
          customTranformersPath: require.resolve('./ts_transformers'),
        }
      }
    ]

@Igorbek
Copy link

Igorbek commented Jul 1, 2017

I would suggest to change required shape of a module being treated as custom transformers configuration.

I have two considerations:

  1. returning a function making impossible to use es modules
  2. constraining to just a single function prevents further extending if we need more complex objects/functions passed down to forked processes.

My proposal is the following:

  1. Add the following option:
export interface LoaderConfig {
    optionsModule?: string;
}
  1. Forked process as well as in-proc version, would resolve the module, if it is specified, and would expect the following module shape:
export interface OptionsModule {
    options?: {
        getCustomTransformers?(): ts.CustomTransformers | undefined;
    };
}

it would allow such modules be extended in the future with something related to options as well as something unrelated.

@goloveychuk
Copy link
Contributor Author

@Igorbek
it would make more difficult to setup ATL for other users, who don't use customTransformers.
Or it could support 2 ways. But this, really, don't look "webpack way".
So when you look at webpack.config, you should see whole configuration, explicitly. When you have path to config - it makes understanding harder.

@Igorbek
Copy link

Igorbek commented Jul 1, 2017

Oh, I'm not suggesting to replace configuration altogether with that. I'm saying that the module should be able to be widened in the purpose in the future. To not restrict ourselves to one single option.

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

Successfully merging this pull request may close these issues.

3 participants