@handbook/source
v1.1.0
Published
[](https://www.npmjs.com/package/@handbook/source) [](https://github.com/rocket-hangar/handbook/actions?query=workflow%3ATe
Readme
@handbook/source
What is this?
You can use this when you need to import a module with its source code together.
For example,
import { source } from '@handbook/source';
const { module: foo, source: fooSource1 } = source(require('./foo'));
const { module: fooImport, source: fooSource2 } = source(() => import('./foo'));The source() function will transform the source into the below.
import { source } from '@handbook/source';
const { module: foo, source: fooSource1 } = source({
module: require('./foo'),
source: require('!!raw-loader!./foo'),
filename: 'foo.ts',
});
const { module: fooImport, source: fooSource2 } = source({
module: () => import('./foo'),
source: require('!!raw-loader!./foo'),
filename: 'foo.ts',
});⚠️ source() function is just an identifier. You have to set @handbook/babel-plugin on your babel configuration.
See more
@handbook/*This package is one of@handbook/*packages. Go to the project home and see more details.
