Comments (12)
It's still too early as a spec to be supported by default (when it changes, we'd have to change all users)
Fair enough! I was just curious whether your stance on support for importing non-JS files was based on design principle or based on the current status of the standards. I take from your message that it's due to the latter.
from create-snowpack-app.
Snowpack should be building your file properly, but right now we only support the following two non-JS imports:
What's your use-case here / what behavior are you expecting? Would love to make this work for you.
from create-snowpack-app.
I am on the aurelia core team and we are trying to build out an official template. I have successfully ran code through our custom plugin but the default method of import is to import template from './my-html.ts' This leads us to aurelia free code. We can explicitly set the values to a string, but most our users want the very simple non import version.
from create-snowpack-app.
manually users can do this no problem
@customElement(name:'test', template: '<div></div>')
export class Test
// but the plugin is this
export class Test
// which generates
import template from './test.html';
@customElement(name:'test', template)
export class Test
from create-snowpack-app.
you want me to tackle this or is this something you guys can take on fairly easily?
from create-snowpack-app.
When you say tackle, are you able to do this in your plugin?
// input
compile `export class Test`
// output
@customElement(name:'test', template: '<div></div>')
export class Test
If so, I'd say yes. We're trying to be very limited in our support for importing non-JS files. We will probably need to support customizing this one day, but for where we are at today it's a bit out of scope. Happy to get creative here tho to make this use-case work for you.
from create-snowpack-app.
We're trying to be very limited in our support for importing non-JS files
What about HTML modules when they make it into the spec / are implemented?
https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/HTMLModules/explainer.md
https://groups.google.com/a/chromium.org/forum/#!msg/blink-dev/ewfRSdqcOd8/w_Fr6rJ3DQAJ
from create-snowpack-app.
It's still too early as a spec to be supported by default (when it changes, we'd have to change all users) BUT I'm definitely not opposed as an opt-in plugin when we get the plumbing in place for a good plugin system.
from create-snowpack-app.
Just thinking out loud here, could it be an idea to make a MIME-based protocol as a fallback for non-JS (or otherwise non-specced) file types? As an explicit opt-in, so that when something makes it into the spec as a new module type, you would still be spec compliant by default.
You could stick to standardized MIME types with known extensions (such as those aggregated in this database), and use that to transform file content to an export default
with a raw string (in the case of UTF8) or otherwise as an ArrayBuffer.
Then, there is still the issue of webpack having import * as someResource
syntax which would be incompatible with export default
, but that could technically also be solved with a simple import rewrite (e.g. import * as someResource
=> import { default as someResource }
)
Or would that be opening a can of worms for snowpack?
from create-snowpack-app.
It sounds like you're describing something close to the same goals as this proposal: https://github.com/tc39/proposal-module-attributes
from create-snowpack-app.
Yep, I was actually (implicitly) referring to that spec. So I was thinking along the lines of a non-conflicting polyfill. However it's understandable if you prefer to just go with stage 3 & higher proposals.
from create-snowpack-app.
Yup, I'm sure this is what we go with eventually but its just too early to support now (or, there was also an asset
proposal that would let you do things like import asset './foo.html'
. Not sure if that's made any progress tho).
from create-snowpack-app.
Related Issues (20)
- Babel Plugin import not working with snowpack HOT 1
- [webpack] Support non-SPA use-case HOT 1
- [plugin-webpack] Not compatible with [app-template-vue] HOT 1
- [plugin-webpack] Production builds: No bundle splitting based on `import(...)` directives HOT 9
- [plugin-svelte] Can not find App.css.js HOT 3
- Provide a blank template for Typescript HOT 4
- Feature request: Add pnpm as install option HOT 5
- Building is broken for Svelte HOT 5
- Add support for creating .gitignore from template HOT 5
- Can we have cli wizard prompts? HOT 6
- @snowpack/app-template-blank-typescript does not exist on NPM HOT 5
- onboard validations to ensure that the respective package manager is installed HOT 4
- plugin-dotenv doesn't work HOT 2
- [plugin-webpack] granular chunking for multi-page apps?
- [@snowpack/app-template-11ty] - HMR issue eleventy templates HOT 1
- Migrating Reactboilerplate app into CSA failing HOT 2
- [@snowpack/plugin-webpack] Use public path instead of baseUrl HOT 1
- [pnpm] missing dependencies in app-template-react-typescript (--use-pnpm) HOT 2
- svelte-typescript-template HOT 1
- Vue cannot use PostCSS in style tag. HOT 1
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 create-snowpack-app.