diff --git a/src/jsx-loader.js b/src/jsx-loader.js index 2d484c1..1bddb77 100644 --- a/src/jsx-loader.js +++ b/src/jsx-loader.js @@ -6,10 +6,8 @@ import escodegen from 'escodegen'; import fs from 'fs'; import jsx from 'acorn-jsx'; import { parse, parseFragment, serialize } from 'parse5'; -import path from 'path'; -import { URL, pathToFileURL } from 'url'; -const baseURL = pathToFileURL(`${process.cwd()}/`).href; +const baseURL = new URL(`file://${process.cwd()}/`); const jsxRegex = /\.(jsx)$/; // TODO same hack as definitions @@ -25,7 +23,7 @@ function getParse(html) { } export function getParser(moduleURL) { - const isJSX = path.extname(moduleURL.pathname) === '.jsx'; + const isJSX = moduleURL.pathname.split('.').pop() === 'jsx'; if (!isJSX) { return; diff --git a/src/wcc.js b/src/wcc.js index ae9b9aa..234982e 100644 --- a/src/wcc.js +++ b/src/wcc.js @@ -8,7 +8,6 @@ import escodegen from 'escodegen'; import { getParser, parseJsx } from './jsx-loader.js'; import { parse, parseFragment, serialize } from 'parse5'; import fs from 'fs'; -import path from 'path'; function getParse(html) { return html.indexOf('') >= 0 || html.indexOf('') >= 0 || html.indexOf('') >= 0 @@ -74,9 +73,10 @@ function registerDependencies(moduleURL, definitions, depth = 0) { ImportDeclaration(node) { const specifier = node.source.value; const isBareSpecifier = specifier.indexOf('.') !== 0 && specifier.indexOf('/') !== 0; + const extension = specifier.split('.').pop(); // TODO would like to decouple .jsx from the core, ideally - if (!isBareSpecifier && ['.js', '.jsx'].includes(path.extname(specifier))) { + if (!isBareSpecifier && ['js', 'jsx'].includes(extension)) { const dependencyModuleURL = new URL(node.source.value, moduleURL); registerDependencies(dependencyModuleURL, definitions, nextDepth);