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
Reconfigure webpack for pollyfilling and tree shaking #37
Changes from all commits
3696f10
2f2720c
a92b811
5d437b3
4a39b3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,22 +17,29 @@ const copies = { | |
const { eslintConfig, main: entryPoint } = require(resolveExtensionPath("package.json")); | ||
const eslintEnabled = eslintConfig || fs.readdirSync(extensionPath).find(f => f.startsWith(".eslintrc")); | ||
const jsLoaders = [{ | ||
loader: require.resolve("babel-loader"), | ||
loader: "babel-loader", | ||
options: { | ||
presets: [ | ||
[require.resolve("@babel/preset-env"), { | ||
targets: { | ||
chrome: 45, | ||
safari: "9.1", | ||
firefox: 45 | ||
[ | ||
"@babel/preset-env", | ||
{ | ||
useBuiltIns: "usage", | ||
corejs: 3, | ||
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 think we should add 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. It's already added. |
||
modules: false, // Should be false to run tree shaking. See: https://webpack.js.org/guides/tree-shaking/ | ||
targets: { | ||
chrome: 62, | ||
safari: 11, | ||
firefox: 59, | ||
edge: 15 | ||
} | ||
} | ||
}] | ||
] | ||
] | ||
} | ||
}]; | ||
|
||
if (eslintEnabled) { | ||
jsLoaders.push(require.resolve("eslint-loader")); | ||
jsLoaders.push("eslint-loader"); | ||
} | ||
|
||
module.exports = { | ||
|
@@ -59,4 +66,4 @@ module.exports = { | |
}), | ||
new ManifestBuilder(extensionPath, bundleName) | ||
] | ||
}; | ||
}; |
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.
If I remember it right, this helps when you run zem locally within its own directory.
How is your local development workflow? If we have a better way to run/test zem locally we can get rid of this.
☝️ We have another
require.resolve
usage in this module.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.
I found several places that we use
require.resolve
and fix it. As far as I understandrequire.resolve
import the module and return the file path instead of module itself. In our case this is redundant, since webpack can resolve the module from file name.We also use it at manifest-builder:
delete require.cache[require.resolve(pkgInfoPath)];
. I'm not sure that we should remove from here also. That's why I didn't remove it.