Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Jun 11, 2020
1 parent 859590f commit 604e564
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 6 deletions.
89 changes: 89 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"@types/babel__traverse": "^7.0.7",
"@types/cacache": "^12.0.1",
"@types/compressible": "^2.0.0",
"@types/css-modules-loader-core": "^1.1.0",
"@types/es-module-lexer": "^0.3.0",
"@types/etag": "^1.8.0",
"@types/http-proxy": "^1.17.4",
Expand Down
11 changes: 6 additions & 5 deletions src/commands/build-util.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Core from 'css-modules-loader-core';
import type Core from 'css-modules-loader-core';
import type {EventEmitter} from 'events';
import execa from 'execa';
import path from 'path';
import {statSync} from 'fs';
import npmRunPath from 'npm-run-path';
import path from 'path';
import {
SnowpackConfig,
BuildScript,
SnowpackConfig,
SnowpackPluginBuildArgs,
SnowpackPluginBuildResult,
} from '../config';
Expand Down Expand Up @@ -53,6 +53,7 @@ export function wrapImportMeta({
);
}

let _cssModulesLoader: Core;
export async function wrapCssModuleResponse({
url,
code,
Expand All @@ -66,8 +67,8 @@ export async function wrapCssModuleResponse({
hasHmr?: boolean;
config: SnowpackConfig;
}) {
let core = new Core();
const {injectableSource, exportTokens} = await core.load(code, url, () => {
const core: Core = _cssModulesLoader || new (await import('css-modules-loader-core')).default();
const {injectableSource, exportTokens} = await core.load(code, url, undefined, () => {
throw new Error('Imports in CSS Modules are not yet supported.');
});
return `
Expand Down
3 changes: 2 additions & 1 deletion src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import cacache from 'cacache';
import chalk from 'chalk';
import chokidar from 'chokidar';
import isCompressible from 'compressible';
import etag from 'etag';
import {EventEmitter} from 'events';
Expand Down Expand Up @@ -874,6 +873,8 @@ export async function command(commandOptions: CommandOptions) {
}
}

const chokidar = (await import('chokidar')).default;

// Watch src files
async function onWatchEvent(fileLoc) {
handleHmrUpdate(fileLoc);
Expand Down

0 comments on commit 604e564

Please sign in to comment.