Open fs86 opened 2 years ago
@fs86 sorry for the long delay. It looks like your demo repo isn't available anymore. Can you recreate it?
I'm using a revised code not occuring any bug, but transformation never be happened.
When I trace the program
parameter, there're not any source file in the program
.
For reference, version of @craco/craco
is 7.0.0-alpha.8
.
const craco = require("@craco/craco");
const webpack = require("webpack");
const transform = require("typescript-json/lib/transform").default;
const throwError = (message) =>
craco.throwUnexpectedConfigError({
packageName: "craco",
githubRepo: "gsoft-inc/craco",
message,
githubIssueQuery: "webpack",
});
module.exports = {
webpack: {
plugins: [
new webpack.DefinePlugin({
process: {
env: {}
}
}),
new webpack.ProvidePlugin({
Buffer: ["buffer", "Buffer"],
}),
],
configure: (config) => {
// ADD TS-LOADER
const { isAdded: tsLoaderIsAdded } = craco.addBeforeLoader(
config,
craco.loaderByName("babel-loader"),
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: "ts-loader",
options: {
// TRANSFORMED, BUT NOT BUNDLED
getCustomTransformers: (program) => {
console.log(program.getSourceFiles()); // NO FILE
return {
before: [transform(program)],
}
},
},
},
);
if (!tsLoaderIsAdded) throwError("failed to add ts-loader");
// REMOVE BABEL
const { hasRemovedAny, removedCount } = craco.removeLoaders(
config,
craco.loaderByName("babel-loader"),
);
if (!hasRemovedAny) throwError("no babel-loader to remove");
if (removedCount !== 2)
throwError("had expected to remove 2 babel loader instances");
return config;
},
},
};
Anyone get this same issue? (Edit: gonna take that as a no, looks like it's eject time! Don't know why everyone is so afraid of ejecting... sounds a little uninformed)
The use-ts-loader recipe (https://github.com/gsoft-inc/craco/blob/master/recipes/use-ts-loader/craco.config.js) does not seem to work correctly. The url-loader is not found and the process terminates at line 37. I have prepared an example repository where the error is reproducible: https://github.com/fs86/use-ts-loader
EDIT: Is this possibly related to the missing CRA5 support?