Comments (8)
Believe it or not, this actually makes sense since BabelMultiTargetPlugin.loader
isn't being used for the vue
files. If the loader isn't used and it's dynamically imported, the plugin won't try to target it. It doesn't work when I just add it in, I'm guessing because it emits more than just JS, so it's going to need some more logic to pick out the JS chunks.
EDIT: I've got a proof-of-concept solution in v1.0.1-alpha.3. It requires adding BabelMultiTargetPlugin.targetingLoader
to your vue rule loaders, which doesn't actually do anything except function as a marker so the plugin knows it's supposed to be targeted.
from webpack-babel-multi-target-plugin.
I've revamped the BabelMultiTargetPlugin.loader
usage a bit - you'll now replace your 'vue-loader'
with BabelMultiTargetPlugin.loader('vue-loader')
in your .vue
rule, in addition to using BabelMultiTargetPlugin.loader()
in your .js
rule. Since it's a breaking change, it's in v2.0.0-alpha.1. Let me know if this gets you up and running, and I'll cut the non-prerelease.
from webpack-babel-multi-target-plugin.
That's amazing! Thanks for your work to bring this plugin forward!
v2.0.0-alpha.1 works for me for a simple vue-loader setup.
However I'm getting errors when dynamically importing plain JS code from Vue components. I prepared another small example: https://github.com/rangermeier/webpack-babel-multi-target-plugin/tree/feature/example-vue-dynamic-import (please let me know if I should submit a PR for this, or should merge it with the vue-cssextract example)
When a file is dynamically imported at two or more points in an application, there's an error Module not found: Error: Unexpected lazy module request, likely due to mixing ES Harmony and CommonJs imports of @angular/core
, the build however passes but the dependency is built in only one of modern/legacy targets.
from webpack-babel-multi-target-plugin.
This one's a little trickier. I'm getting a two pairs of requests for the dependency file, I'm guessing because at that point, Webpack doesn't realize it's the same module (since I change the request when targeting). In other use cases, this generally indicates an error, as you can tell from the error being thrown. Looks like I might need to allow the same file to get blind targeted more than once.
Also, thank YOU for working with me on this and helping me get Vue properly supported. I appreciate being able to check against someone with a real world use case rather than just trying to come up with a contrived example myself.
from webpack-babel-multi-target-plugin.
Okay, some progress! v2.0.0-alpha.2 should work without using that webpackChunkName
annotation - it ends up using numbered file names, which I understand is less desirable, but it does seem to work.
However, when using the webpackChunkName
annotation, it looks like it tries to merge the otherwise separate targeted chunks. I'll need to look further into how that feature works so I can figure out how to get the chunk tagged correctly so you end up with, for example, dep.js
and dep.modern.js
.
Update - fixed chunk naming in v2.0.0-alpha.3
from webpack-babel-multi-target-plugin.
v2.0.0-alpha.3 fixes the issue with dynamic imports, also named chunks are working for me now. However I encountered another problem with normal imports of npm modules, see #8 .
Again, thank you for working on this plugin.
from webpack-babel-multi-target-plugin.
So, a couple things:
This wasn't actually an issue with the plugin - moment requires (ha!) a little finessing when used in an ES6 environment. I added a resolve
alias for it, and it's working now - though it's still showing a warning for loading locale data, so you'll need to do something more for that (look around for using ContextReplacementPlugin
to load only the locales you need instead of ALL of them).
That said, it might be worth looking into using a different library like Luxon to get the most out of ES6 and things like tree shaking.
Also, the syntax for using the module from dependency.js
was wrong - default exports get shoved behind a .default
property when imported like that, so I just changed it to use a named export.
from webpack-babel-multi-target-plugin.
Assuming there aren't any further issues, I'm going to close this and cut 2.0.0.
from webpack-babel-multi-target-plugin.
Related Issues (20)
- support deduplicating CSS from dynamic import modules
- Unable to import 'crypto' when plugin is used HOT 4
- Switch to core-js 3.x not mentioned in 2.3.1 release changelog HOT 4
- Upcoming Webpack5 compatibility HOT 6
- TypeError: Cannot read property 'descriptionFileRoot' of undefined HOT 11
- presets for babel HOT 3
- use single runtime chunk will cause error HOT 3
- fork-ts-checker emits error HOT 3
- Runtime error when using webpack-dev-server
- v2.5.0 HOT 9
- BlindTargetErrors when building @tanker and subscriptions-transport-ws HOT 2
- [2.5.0-next.2] ContextReplacementPlugin apparently ignored HOT 2
- Angular: The AngularCompilerPlugin was not found HOT 6
- Use Browserslist config HOT 2
- TypeError: "exports" is read-only HOT 4
- mini-css-extract-plugin crashes with tagAssetsWithKey HOT 2
- htmlWebpackPluginAlterAssetTags is undefined HOT 8
- Vue scoped css only work in nomodule
- moment.js locale not loaded
- 'babel-loader' cannot be found when using npm 7.20.3+
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack-babel-multi-target-plugin.