terpiljenya / import-glob Goto Github PK
View Code? Open in Web Editor NEWES6 import with glob patterns (preloader for Webpack)
ES6 import with glob patterns (preloader for Webpack)
my app's root is set like this
config.resolve = {
root: path.resolve(__dirname, '../app')
};
so that if i am importing a file at app/img/foo.png, i can say
import 'img/foo.png'
instead of '../../img/foo.png' or whatever
Is it possible to use the webpack resolution roots to look for files to glob?
Hello! Nice work, but I have problem with import pug-template.
I used
"import "./**/*.pug"
in my entry point and ive got error after start webpack
Module not found: Error: Cannot resolve 'file' or 'directory' ./**/*.pug in {my_frontend_directory}
Where am I wrong?
Is this compatible with v5 of webpack ?
If the glob pattern matches no filenames, the loader returns an empty string. It should probably return an empty array, so that code like this:
import foo from './*.bar';
console.log(foo);
Doesn't result in "foo is not defined"
Sweet plugin! Small issue with it though = if you add/remove a file in the glob pattern webpack doesn't pick up the changes until you completely restart.
Is there a way to watch the folder and re-compile?
Node's glob package has an option nodir
(https://github.com/isaacs/node-glob#options) that would have value here.
Suppose I have main.ts
:
import './app/**/*.module'
Notice that I omitted the file extension. This should grab all module files first and process them. However, the glob use in this project doesn't seem to have an option for ignoring directories. That means, for example, if I'm using the TypeScript loader, I get 'failed to find' errors - because glob returns directories, and awesome-typescript-loader can't parse a directory.
To fix, I have to
import './app/**/*(.js|.ts)'
Which is tolerable, but also defeats the value of webpack - suck up everything and process via the appropriate loader.
Please advise/weigh in.
works
import foo from '../../../js/foo/*';
console.log(foo);
doesnt work
import foo from 'foo/*';
console.log(foo);
the alias is added in webpack properly.
Is it possible to introduce error handling for multiple imports when either the path or the match criteria is wrong. Presently it throws
TS2304: Cannot find name
error when the import fails for e.g.
import modules from './wrongpath/**/wrongMatch.**';
and the modules variable disappears and cannot be debugged.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.