Giter Site home page Giter Site logo

Comments (12)

fkleuver avatar fkleuver commented on September 14, 2024 1

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.

FredKSchott avatar FredKSchott commented on September 14, 2024

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.

brandonseydel avatar brandonseydel commented on September 14, 2024

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.

brandonseydel avatar brandonseydel commented on September 14, 2024
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.

brandonseydel avatar brandonseydel commented on September 14, 2024

you want me to tackle this or is this something you guys can take on fairly easily?

from create-snowpack-app.

FredKSchott avatar FredKSchott commented on September 14, 2024

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.

fkleuver avatar fkleuver commented on September 14, 2024

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.

FredKSchott avatar FredKSchott commented on September 14, 2024

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.

fkleuver avatar fkleuver commented on September 14, 2024

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.

FredKSchott avatar FredKSchott commented on September 14, 2024

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.

fkleuver avatar fkleuver commented on September 14, 2024

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.

FredKSchott avatar FredKSchott commented on September 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.