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
Switch from ts-loader to babel-loader #2449
Changes from 4 commits
3b0daf7
da5355b
45511ca
70a909b
00a1e58
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
const { environment } = require('@rails/webpacker') | ||
environment.loaders.delete('typescript') | ||
|
||
module.exports = environment |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const { join, resolve } = require('path') | ||
const { cache_path: cachePath, source_path: sourcePath, resolved_paths: resolvedPaths } = require('../config') | ||
const { nodeEnv } = require('../env') | ||
|
||
// Process application TypeScript code with Babel. | ||
// Uses application .babelrc to apply any transformations | ||
module.exports = { | ||
test: /\.(ts|tsx)?$/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @gopeter Can we use the same babel loader to enable typescript as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be possible if we add the ts/tsx extensions to it. But then Babel would be able to parse Typescript files, even without running But: we may could add the ts/tsx extensions to the current Babel config in the Typescript install script. Then we could also remove the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I think that's fine. It wouldn't do anything for people who aren't using typescript but will probably fail if they are using typescript and don't have tsconfig.json? But perhaps not, since some of default options would on in the preset itself, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please test by including extensions as default? |
||
include: [sourcePath, ...resolvedPaths].map((p) => resolve(p)), | ||
exclude: /node_modules/, | ||
use: [ | ||
{ | ||
loader: 'babel-loader', | ||
options: { | ||
cacheDirectory: join(cachePath, 'babel-loader-node-modules'), | ||
cacheCompression: nodeEnv === 'production', | ||
compact: nodeEnv === 'production' | ||
} | ||
} | ||
] | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to do this?