Ncc: Extending asset imports

Created on 12 Apr 2019  路  4Comments  路  Source: vercel/ncc

I currently use webpack directly on my project. I am interested in using this project but I have a raw-loader configured in my webpack.config.js to import *.sql$ files. E.g.

import SQL_TEMPLATE from './insert-rows.sql'
const statement = database.prepare(SQL_TEMPLATE)
statement.run(...)

Are there plans to change the default static asset imports? Or even default to importing unrecognizable extensions as strings?

Most helpful comment

There's a proposed asset keyword by @sebmarkbage that would solve all our problems. We just need to send a PR to TC39 and merge it to master.

All 4 comments

There's a proposed asset keyword by @sebmarkbage that would solve all our problems. We just need to send a PR to TC39 and merge it to master.

@andykais you can try using the loader - https://github.com/zeit/webpack-asset-relocator-loader directly in your webpack project. That should compose with custom extension loaders fine.

@guybedford thats a neat project! I was exploring options to add a require.extensions['.sql'] handler manually and that loader seems to do just that. However, until I actually switch to ncc, raw-loader is definitely the better option because it simply treats my sql imports as strings, so there is no IO to perform.

@rauchg can you elaborate on ncc's roadmap here? I think I found @sebmarkbage's proposal in question. Are you planning on creating a babel plugin to handle the asset keyword? Do you plan to only support importing assets once this proposal (or one like it) makes it to TC39 stage 4? I ask because waiting for a proposal to make it into v8 could take years.

If so, what is your plan as a workaround for asset importing for the time being? Do you plan on using the webpack-asset-relocator-loader or making the webpack config extendable?

Sorry if thats a lot of questions, I am just curious what the plan is for ncc.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tmtron picture tmtron  路  5Comments

mrmckeb picture mrmckeb  路  5Comments

rgbkrk picture rgbkrk  路  3Comments

GiladShoham picture GiladShoham  路  3Comments

tomakado picture tomakado  路  4Comments